From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

traité une image par matlab script sur Labview

salut!! j'ai un programme Matlab qui fait le traitement d'image , je veux l’exécuter sous Labview et recevoir le resultas sous Labview auss . je sais pas comment faire la conversion Array to image si quelqu'un Peut m'aider Merci !!

 ci joint le programme utilise 

0 Kudos
Message 1 of 19
(13,014 Views)

Hey Aziz,

 

I hope you're doing well today! You'd first have to output the variable or array that you'd like to convert from the Script Node into the LabVIEW environment. Then you could convert that array into a pixel map or whatever image format you would like. Do you know what kind of image formatting you plan on using?

 

Here's some more information to help get you started:

http://zone.ni.com/reference/en-XX/help/371361E-01/gmath/matlab_script_node/

 

Cheers,

Tim A.
0 Kudos
Message 2 of 19
(12,990 Views)

Hello !!

 

 

thank you very much for answering my question!!  well I searched information about the matlabscript node and i could do  the following program where the type of image is an RGB (U32). i also think in using a  webcam so i will get an image from tha camera and try to process this image with th matlab functions of image processing. the problem for me is that  i lose one color . for example in the figure 3 in my program i have a blue background for all the images i use.  do you have any idea about why i have this and how i can solve it ??

 

have a great day !!

 

 p.s : I was searching in the Forum and i found this but i didnt understand it :

 http://forums.ni.com/t5/LabVIEW/Help-Display-Image-in-Labview-From-MATLAB-Script-Node/m-p/767817?req...

0 Kudos
Message 3 of 19
(12,983 Views)

Hey aziz,

 

Could you possibly show me a screenshot of the behavior that you're seeing on the images? I dont have the image file that you're working with so its hard for me to visualize. I'm also not too familiar with the functions that you're working with in the script node. Can you elaborate a bit more on what you expect from those functions?

 

What is the intended outputs of the imfilter() and the deconvwnr() functions?

 

Also, does this script work correctly in the MATLAB ® environment? or is it only within LabVIEW that you see it not functioning correctly?

Tim A.
0 Kudos
Message 4 of 19
(12,966 Views)

Hello !!

 

sorry for being late in my answer , I had to finnish other work!! and thank you for answering 

 

here are the uses of  the functions that you asked me,   from the help of Matlab !!

IMFILTER N-D filtering of multidimensional images.

 

B = IMFILTER(A,H,OPTION1,OPTION2,...) performs multidimensional
filtering according to the specified options.

Options are:

 

'circular'        Input array values outside the bounds of the array are computed by implicitly assuming the input array is periodic.

 

'conv'            IMFILTER performs multidimensional filtering using convolution.

 

DECONVWNR      Deblur image using Wiener filter.
J = DECONVWNR(I,PSF)   deconvolves image I using Wiener filter algorithm,

                                         returning deblurred image J. The assumption is that the image I was
                                         created by convolving a true image with a point-spread function PSF and
                                         possibly by adding noise. The algorithm is optimal in a sense of least
                                         mean square error between the estimated and the true images, and
                                         utilizes the correlation matrixes of image and noise. In the absence of
                                         noise, the Weiner filter reduces to the ideal inverse filter.

Finally as you can see in the archives joined to this message , the results of Matlab and Labview are different , so i think that the problem is with the conversions of the type inLabview  from image to array and array to image where i lose information of the image.

 

 

have a nice day !! 

 

thank you !!

0 Kudos
Message 5 of 19
(12,955 Views)

The part that i'm worried about in the code is the data type conversions,I've circled the places in the code where we have data type conversions.

 

picture.JPG

 

Im wondering if the data type change when the code goes from the LabVIEW environment through the script node is causing it to be distorted before you even process any filtering. I would check to make sure that the image when it is first being read in the MATLAB environment is not incorrectly displayed or distorted to start.

 

You may have to find another way to represent the U32 array data before you pass it through the script node that must be a Floating data type.

Tim A.
0 Kudos
Message 6 of 19
(12,945 Views)

hello !!

 

yes i agree with you, and this exactly the problem that Im searching for the solution here !! I trayed alot of solutions but i always have the same problem with the images in color Smiley SadSmiley Sad , (without colors, like  grayscale U8,U16,I16..., it gaves the same results as Matlab ).

 

ok Im still working in this , if I find any solution i will inform you Smiley Happy !!

 

have a nice day !!

0 Kudos
Message 7 of 19
(12,941 Views)

Ah, glad we're on the same page! The first thing to identify should be the data type that the function in the script node typically handles. I know in LabVIEW we're working with a U32 that is shaped with ,

 

Bits 0-7 are Blue

Bits 8-15 are Green

Bits 16-23 are Red

 

I wonder if this is the same formatting that's being expected for the filter calculations in the script node? I wonder if the order is different for the MATLAB function basically.

 

Another thing we can check is, once we send in the the file through the Script Node, we should confirm that that file is still showing correctly. This can help us solidify whether there is an issue with the U32 to double conversion. My guess is that the changing of data types, which is causing the image to be distorted in color, occurs during the filter functions in the script node.

Tim A.
0 Kudos
Message 8 of 19
(12,937 Views)

Hi all.

 

 

I am also facing the same problem. I  need to read a color image but was unable to read through matscript node. In the mathscript I am doing color image segmentation. So I need to be able to read color image from labview to matlab.  please suggest me how to handle this problem.  Here i am attaching my file.  Thanks in advance...

0 Kudos
Message 9 of 19
(12,566 Views)

Howdy eswar1,

 

The problem that Aziz was facing before is actually a bit different because it is using the MATLAB ® Script Node in LabVIEW and you're using the MathScript Node. So, there is actually a bit of a difference in the troubleshooting steps needed. I recommend reposting this question to a new thread as it is different. This should be done for any new questions that you might have even if it is the same problem. In the new post, you can refer to another thread as being related.

Tim A.
0 Kudos
Message 10 of 19
(12,559 Views)