From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Load Jpeg and convert to 8 bit grayscale array?

Hi,
 
I am trying to load a jpeg image and convert it to a grayscale array (0-255 depth) but I am having an awful time.  I did this previously with the Vision evaluation module using image to array functions but I am trying to do it with the graphics pallette that is free.  Does anyone know where my problem lies?
 
I am loading the image with the Read Jpeg file.vi I selected use 8 bit color table and i then am using an unflatten pixmap to extract an array but clearly these values are not representative of the grayscale image pixel values (they seem like RGB Values).  I need the grayscale values so I can identify a dark edge by passing the array in a for loop and checking for a grayscale value.
 
So how do I upload a jpeg and convert it to a 8 bit greyscale array so I can get my edges?
 
Thanks for your help
 
0 Kudos
Message 1 of 23
(14,106 Views)

Hi Chris,

to convert a RGB value to a grayscale value use this formula: "gray = 0.299R+0.587G+0.114B". To detect your edge see something like "Sobel-Operator", "Prewitt-Operator", or .... .

Mike

0 Kudos
Message 2 of 23
(14,098 Views)

Mike I am not sure how to use the gray level formula you provided all I have is an array of integers.

But here is some more clarification of what i am trying to do and have done because I read my previous post and it seemed confusing.  Sorry about that Smiley Wink that was due to frustration.

I am loading and clipping a jpeg that is a monochrome image.  I want to turn this clipped image into an array that maps out the gray level (0-255) of each pixel in a 2 D array and I don't have IMAQ Image to Array function.  How would I do this with just the graphics palette included in the development edition of Labview?

I tried using the unflatten pixmap vi but the 8 bit output array is not what I am looking for the numbers are not 0-255 or seem to represent gray because it gives a color image when I display it.  How do I convert each number in the array to its 0-255 grayscale representation?  Attached are two pictures that show what I have.  As far as Identifying the edges I do have a vi that does this that I created from a program I made previously it just requires the grayscale 0-255 image array and thats what has me stressed Smiley Sad.

Download All
0 Kudos
Message 3 of 23
(14,080 Views)

Hi Chris S.,

here is an example for you. The formula is integrated. Hope it helps.

Mike

0 Kudos
Message 4 of 23
(14,070 Views)
Hi Mike,
your VI didn't work for me, since the RGB- Values are packed in triplets. I changed your VI, now it works.
greets, Dave
Greets, Dave
Message 5 of 23
(14,056 Views)

Hi daveTW,

my vi work in this way i want. Because Chris only want a 2D Array of grayscale values.

Mike

0 Kudos
Message 6 of 23
(14,043 Views)
Wow Mike,
 
That was exactly what I was looking for.  I am very impressed and delighted that people like you take the time to help frustrated folks like myself.
 
Tremendous Thanks,
Chris
0 Kudos
Message 7 of 23
(14,033 Views)
Hi all, Im having the same problem, but I cant open this examples because I have the version 7.1. If somebody can help me with it I'll appreciate.
0 Kudos
Message 8 of 23
(13,433 Views)

Hi Anfego,

attached you will find a picture of the improved code.

Mike



Message Edited by MikeS81 on 07-22-2008 09:50 AM
0 Kudos
Message 9 of 23
(13,397 Views)
Mike,
         Extracting a single plane should convert the jpeg image to a 8-bit grayscale image right?
Message 10 of 23
(13,390 Views)