LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help : Display Image in Labview From MATLAB Script Node

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.

0 Kudos
Message 1 of 9
(7,139 Views)
Can you attach your code for lv 8.0?
0 Kudos
Message 2 of 9
(7,132 Views)

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.

 

 

Message Edited by smercurio_fc on 08-27-2008 10:39 AM
Message 3 of 9
(7,105 Views)
Thank you. Yes I am aware I  can you the read JPEG vi node to get my image, but I will be doing many manipulations on the Matrix, so I will like to use MATLAB or MATHSCRIPT script node, but unfortunately mathscript does not have most of the image processing functions.
0 Kudos
Message 4 of 9
(7,092 Views)

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

0 Kudos
Message 5 of 9
(7,086 Views)

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. Smiley Wink 

Download All
Message 6 of 9
(7,069 Views)

Hello !!

 

I have the same problem with the dispaly of an image so please help me if you found a solution !!

 

 

 

thank you 

0 Kudos
Message 7 of 9
(5,984 Views)

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. 🙂

  

Sam S
Applications Engineer
National Instruments
0 Kudos
Message 8 of 9
(5,969 Views)

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 !!

0 Kudos
Message 9 of 9
(5,959 Views)