Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Load Jpeg and convert to 8 bit grayscale array?

651 views
Skip to first unread message

Chris S.

unread,
Feb 12, 2008, 7:10:06 PM2/12/08
to
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
 

MikeS81

unread,
Feb 13, 2008, 11:10:08 AM2/13/08
to
Hi Chris S.,
here is an example for you. The formula is integrated. Hope it helps.
Mike


Grayscale.vi:
http://forums.ni.com/attachments/ni/170/301498/1/Grayscale.vi

Chris S.

unread,
Feb 13, 2008, 11:10:07 AM2/13/08
to
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 :smileywink: 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 :smileysad:.


ImageBlockDia.jpg:
http://forums.ni.com/attachments/ni/170/301495/1/ImageBlockDia.jpg


SprayColored.JPG:
http://forums.ni.com/attachments/ni/170/301495/2/SprayColored.JPG

Chris S.

unread,
Feb 13, 2008, 9:10:04 PM2/13/08
to
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

MikeS81

unread,
Jul 22, 2008, 4:10:07 AM7/22/08
to
Hi Anfego,
attached you will find a picture of the improved code.
MikeMessage Edited by MikeS81 on 07-22-2008 09:50 AM


Unbenannt3.PNG:
http://forums.ni.com/attachments/ni/170/342797/2/Unbenannt3.PNG

MikeS81

unread,
Jul 22, 2008, 4:40:08 AM7/22/08
to
Hi muks,
what do you mean?
Mike

MikeS81

unread,
Jul 25, 2008, 2:40:08 AM7/25/08
to
Hi muks,
i don´t understand what you want to tell me. Can you explain please?
MikeMessage Edited by MikeS81 on 07-25-2008 08:22 AM

muks

unread,
Jul 25, 2008, 3:40:06 AM7/25/08
to
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
I was just  saying that extracting a  single plane from a n RGB image should convert it into  a gray scale image.

Anfego

unread,
Jul 28, 2008, 7:10:05 PM7/28/08
to
Hello Mike, thank you very
much for the quick response. I tried the code and it does not work
for me. The truth is that my problem is other, but I thought it could
be the solution.  
 
Although my problem is this: I've created a matrix of 640x480 floating
point and I need it to show it in grey scale.  I found an example
from NI where a palette of gray is created and used with Flatten Pixmap
box, but this example use the function Join which is it not available
in the 7.1 version, this is the one that I work with.  If anyone
knows how to solve this problem, I'll really appreciate it. 
 
Best regards, Anfego

muks

unread,
Jul 29, 2008, 3:10:07 AM7/29/08
to
my problem is this: I've created a matrix of 640x480 floating
point and I need it to show it in grey scale.
Did you try  array  to  image function ? can you post your  array?

Anfego

unread,
Jul 29, 2008, 9:40:06 PM7/29/08
to

MikeS81

unread,
Jul 30, 2008, 1:40:06 AM7/30/08
to
Hi Anfego,
see the attached example please.
 
Hope it helps.
Mike


fringes[1]_LV85.vi:
http://forums.ni.com/attachments/ni/170/344999/1/fringes[1]_LV85.vi

0 new messages