LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help on converting bmp to 8bit grayscale arrays

I am using Labview 6, and need to read a bmp file and obtain the grayscale values in an array to analyse the data. What is the best way of doing this.
0 Kudos
Message 1 of 12
(5,489 Views)
Look on the functions palette under Graphics & Sound>>Graphics Formats. Use the functions Read BMP File.vi and Unflatten Pixmap.vi.

This should get you on your way. Good Luck,
Scott Menjoulet
0 Kudos
Message 2 of 12
(5,489 Views)
I have already looked at those functions but I dont really know how to use it. Do you know if there are any examples of how to use it?
0 Kudos
Message 3 of 12
(5,489 Views)
Hi,

If you have an array of U32 or I32 from a 24 bit bitmap, each byte represent
one pixel. The format is: bit 0-7 B, 8-15 G, 16-23 R, or R and B switched, I
can't remember.

Use two for loops around the 2d data, and use Split Number to split the 32
bit number to two 16 bit numbers, use the same technique to split the two 16
bit numbers into four 8 bit numbers. Three of these numbers are the three
colors.

This doesn't work if the bitmap is 2,8 or 16 bit... For the 8 bit data, each
byte represents an index in the color table, so you can convert the color
table to three colors, and use each index to lookup the color for that
index. Don't know about the 16 bit data, it might be a 5/6/5, 6/5/5 coding
(for R/G/B) or also a color table, with 65536 entrees.

Regards,


Wiebe.


"mepgkas" wrote in message
news:506500000008000000BD690000-1031838699000@exchange.ni.com...
> I am using Labview 6, and need to read a bmp file and obtain the
> grayscale values in an array to analyse the data. What is the best way
> of doing this.
0 Kudos
Message 4 of 12
(5,489 Views)
Does this apply to grayscale where 8-bit is a range of values from 0-255, I would just like to get the values between 0and 255 for the picture which should be in 8-bit grayscale already.
0 Kudos
Message 5 of 12
(5,489 Views)
Hi,

As far as I can see (creating my own gray scale bitmaps), even grayscale
bitmaps use a color table.

But the way PSP creates them, index 0 is color 0,0,0, index 61 is color
61,61,61.

To be on the safe side, you'll have to use the color table.

So, get the 2d array, make two for loops around it, for each value, pick
this element from the color table, and use autoindexing to build a new 2d
array...

Regards,

Wiebe.


"mepgkas" wrote in message
news:50650000000500000026BA0000-1031838699000@exchange.ni.com...
> Does this apply to grayscale where 8-bit is a range of values from
> 0-255, I would just like to get the values between 0and 255 for the
> picture which should be in 8-bit grayscale already.
0 Kudos
Message 6 of 12
(5,489 Views)
Hi;

Attached is a simple example.

Run the vi and open the file "letterT.bmp", which is a small grayscale image with the letter "T" on it.

You will be able to see the values of the pixels (hexagesimal) in one array and the color associated with the value in the other array.

I hope this is helpful.

Enrique
www.vartortech.com
Message 7 of 12
(5,489 Views)
Thank you for that it was exactly the sort of example i was looking for. is there any way that i can have the numbers instead of hexigecimal? i need to analyse the numbers using this while loop.

I will have two inputs from 2 pictures which the values will go in the ta1 and ta2 sections then i need to get an output array to analyse again. can you help?

I have attached the vi if you try ta1=2200 and ta2=1900 and t2=3000
0 Kudos
Message 8 of 12
(5,489 Views)
Hi mepgkas;

I do not have a clear idea of what you want to accomplish. I tried to go through your vi, but it is not clear to me how it is suppose to work with the images.

In the attachment you will find three VIs. The first (formula_final_2.vi) do the same as your first VI. I just modified it a little to try to understand its operation. I hope you find the modifications helpful.

The second file (formula_final_test.vi) is also your original VI. I modified it to work as a subVI. The third VI (example w gray.vi) uses the second VI as a subVI and input the two images. I assumed that picture 1 should go in ta1, picture 2 should go in ta2 and the resulting array is formed using t2 as it elements. Chances are I am wrong, however, it shoul
d give you a good starting point.

Best regards;
Enrique
www.vartortech.com
0 Kudos
Message 9 of 12
(5,489 Views)
About the hexagesimal format... it is just a way to represent the same numbers. It is like a different language. I find that for images it is easier to read to pixel value in hexagesimal format. However, the numbers need to be integers.

To see the actual number (base 10 format), right click the array, select "Format & Precision..." and in the "Format" pull-down menu select "Decimal".
www.vartortech.com
0 Kudos
Message 10 of 12
(5,234 Views)