08-27-2008 01:09 AM
A color image has 3 dimensions, hence when I use imread in MATLAB to read my image it is a 3D array. but using the MATLAB script node the output can only give out 2D.
My problem is that I want to output the array to display in LabVIEW, using the draw unflattened pixmap, but when I use that, the image has a blue background. The true color of the image is not depicted. Of course, I was not suprised, because the 3D was changed into 2D
I have attached the simple VI to depict what I am trying to accomplish. In the MATLAB script , I use forest.jpg, any image can be used, but the name forest must change. Unfortunately, I have seen this question addressed on this forum but no definite answer has been provided. I do not have easy access to the IMAQ toolkits, even when I went to my school lab, and used the IMAQ, I could not find a solution to this issue.
Any help will be appreciated.
08-27-2008 02:15 AM
08-27-2008 10:39 AM - edited 08-27-2008 10:39 AM
Why don't you just use the built-in functions to read the image. Why are you going through Matlab in order to read an image from disk, stuffing a 3D array down into a 2D array and then trying to deal with that.
08-27-2008 12:13 PM
08-27-2008 12:28 PM
I may be missing something, but why don't you just break the 3D array down into multiple 2D arrays, and pass them out. You can reconstruct the array in LabVIEW. Alternatively, can't you just reshape the array as a 1D array, and then reshape it back to 3 dimensions in LabVIEW. I believe arrays are all stored in a single dimension in memory anyway.
Chris
08-27-2008 02:23 PM
You don't actually need to do that. The 2D array output is all of the data, it's just been reshaped into a 2D. For instance, if in Matlab you read a 55x92 JPEG you'll get a 55x92x3 array. The output of the Matlab script node is a 55x276 array. 92x3=276. Thus, you just need to reorganize the 2D array into the 1D array that the Draw Flattened Pixmap function expects. The tricky part is that you have to interleave the data for the Draw Flattened Pixmap function. You can have the Matlab node spit out the dimensions of the 3D array so you'll know how many rows/columns/pages there are, but you can also figure it out programmatically if you assume the last dimension is always 3.
Attached is a crude way to do it. I just cheated a bit as far as setting the Rectangle boundary. I'm sure you can figure it out on your own.
04-30-2012 05:56 AM
Hello !!
I have the same problem with the dispaly of an image so please help me if you found a solution !!
thank you
05-01-2012 09:53 AM - edited 05-01-2012 09:53 AM
Hello,
Due to the age of the thread that you are posting on I would recommend creating a NEW thread for this issue. Be sure to include all pertinant data so that we can try to address this issue. 🙂
05-02-2012 05:18 AM
Hello Samuel !!
i posted a new thread for this subject here http://forums.ni.com/t5/LabVIEW-MathScript-RT-Module/trait%C3%A9-une-image-par-matlab-script-sur-Lab... . i found this page in the historics about matlabscript . so i thought that someone who had the same problem as me can help quickly !!
i hope that you join us there so that we can exchange more ideas about the topic
thank you !!
have a nice day !!