八度,套接字连接收到的显示图像不显示 [英] Octave, display image received by socket connection does't show
问题描述
我有一个八度音阶脚本,其中我打开一个套接字服务器,并从连接的客户端接收一些命令.这已经有效.现在,我需要将数据(主要是图像)发送到Octave并进行处理.为了对此进行测试,我想接收并显示灰度测试图像.
I have an octave script in which i open a socket server an receive some commands from connected clients. This already works. Now i need to send data to Octave, mostly images and process them. To test this i wanted to receive and display a grayscale test image.
bufflen = 4096;
[data,count]=recv(b,bufflen);
imshow (data)
图像窗口打开,但为空.数据的大小恰好是我要发送的图像文件的大小.我还尝试使用
the image window opens but it is empty. The size of data is exactly the size of the image file i am sending. I also tried saving the image with
imwrite (data, "test.jpg");
这产生了一个文件,但是图像的每一行都排成一行.当我用
this produced a file but every line of the image was in one long line. When i open the image with
imshow test.jpg
一切正常,图像窗口出现并显示图像.
everything works as it should, the image window appears and shows the image.
我正在使用
>ncat.exe 127.0.0.1 12346 < test.jpg
这似乎可行,我能够将图像传输到另一台PC上并在那里查看.
this seems to work, i was able to transfer the image to another pc and view it there.
每个提示或技巧都非常感谢,谢谢.
Every hint or tip is greatly appreciated, thank you.
推荐答案
您正在将jpeg作为字节流(ncat.exe 127.0.0.1 12346 < test.jpg
)发送,但是您尝试使用imshow
来显示它,因为它将是未压缩的RGB灰度或索引图片.您可以接收它并将其保存到临时文件中,然后使用imread加载它.在这种情况下,图形/图像魔术师将对您进行从JPE到RGB的解压缩.
You are sending your jpeg as byte stream (ncat.exe 127.0.0.1 12346 < test.jpg
) but you are trying to show is with imshow
as it would be an uncompressed RGB, grayscale or index image. You can receive it and save it to a tempfile and then load it with imread. In this case graphics/image-magick will do the uncompression from JPE to RGB to you.
这篇关于八度,套接字连接收到的显示图像不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!