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

cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion colors Labview to color Matlab

Hi

My VI open a png file of an oscilloscope and then creates a file txt with all colors of pixels, that I analyze with a C++ program to obtain a matlab file with the coordinates of the pixels of reference and of the curves in the image, such that i can with matlab rotate my image because the curves are crooked.

My question is how can i convert the colors of the curves from labview codification to the matlab codification, such that when i will plot the curves with matlab they will have the same colors of one in the image?

The VI should also let you chose in the front panel the size of the point, the shape and the width of the the line. I was thinking to save them in matlab script and then load later in the matlab script that analyze the coordinates. The problem is that i don't know where to start.

Thank you for your time

 

0 Kudos
Message 1 of 5
(2,834 Views)

Colors in LabVIEW are carried as U32, where the lower 3 bytes are used to store the R, G, and B components (you can ignore the upper byte for this). So, as a first step we need to know how you are writing the text file of color pixels, because there are many possibilities. What is the format of this text file? What information does it contain?

 

I am not sure why you think you need to go to C++ and then to matlab just to rotate a picture. You can easily do that in LabVIEW directly. Why so many steps? Also remember that LabVIEW is big-endian, so you might have (easily solvable) byte order issues when going to a different programming environment.

 

Can you show us an example image and the LabVIEW code you use to write the text file. Then tell us what kind of rotation you want to apply and how the final output should look like. (I guess this is related to your earlier question)

 

 

0 Kudos
Message 2 of 5
(2,811 Views)

In the attached png the curves are crooked because the reference points aren't (0,0);(1,0);(1,1);(0,1). So what will do my matlab script is calculate the matrix of transformation from the coordinates of the pixels of reference, then calculate the inverse of this matrix such that i can multiply each coordinates of the pixels of the curves and then plot them with sin of approximation.

The txt file contain in this order: Width, Height,Number of colors, color of the 1st pixel of reference, color of the 2nd pixel of reference, color of the 3rd pixel of reference, color of the 4th pixel of reference, color 1st curve,..., color n-th curve, color first pixel, color 2nd pixel,......

 

 

 

 

 

0 Kudos
Message 3 of 5
(2,743 Views)

Thanks. For simplicity, I would help if you zip all relevant files into one single attachment. Also tell us the name of the toplevel VI so we don't have to guess. I'll have a look...

0 Kudos
Message 4 of 5
(2,705 Views)

Just glancing at all your code, it seems overly complicated. None of your subVIs need more than one or two loops (only the one creating the histogram needs two). You only have 256 colors, so their indices are 0..255. You do 0.256, which is 257 colors, impossible.)

 

(array indices in matlab are 1 based: first element has index=1, while in LabVIEW it is index=0. Something to keep in mind!)

 

Really, LabVIEW has all the linear algebra and geometry transformations you possibly need. You can do it all right there!

Message 5 of 5
(2,703 Views)