LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

return values of IMAQ GetImagePixelPtr

Hi,

within LabView 5.1.1 on Windows NT I try to manipulate an IMAQ image with a
C programme using a CIN (code interface node). In LabView there exists the
function IMAQ GetImagePixelPtr which returns a pointer on a pixel of the
image (e.g. imagePtr).
I have defined with IMAQ Create an 8 bit image and the applied IMAQ
GetImagePixelPtr. The returned value of the pointer (*imagePtr) is a very
big number (e.g. 35654414) and not as I supposed an 8 bit integer (something
between 0 and 255) which should reflect the brightness of this pixel.

Does anyone has an idea how I can get the brightness information of each
pixel in C?

Thanks a lot,
Gerd
0 Kudos
Message 1 of 5
(3,213 Views)
> within LabView 5.1.1 on Windows NT I try to manipulate an IMAQ image with a
> C programme using a CIN (code interface node). In LabView there exists the
> function IMAQ GetImagePixelPtr which returns a pointer on a pixel of the
> image (e.g. imagePtr).
> I have defined with IMAQ Create an 8 bit image and the applied IMAQ
> GetImagePixelPtr. The returned value of the pointer (*imagePtr) is a very
> big number (e.g. 35654414) and not as I supposed an 8 bit integer (something
> between 0 and 255) which should reflect the brightness of this pixel.
>
> Does anyone has an idea how I can get the brightness information of each
> pixel in C?
>

Without being really familiar with these functions, from the
name, I would expect that function to return a Ptr. A ptr to
the pi
xel. To get the value of the pixel, dereference the
ptr. In otherwords, if the ptr variable is pixPtr, then
pixelValue= *pixPtr;

Greg McKaskle
0 Kudos
Message 2 of 5
(3,213 Views)
You are right, the function returns a pointer, in the manual it says a
pointer on a pixel of the image. What I don't understand is why the
dereferenced pointer has such a big value, i.e. why pixelValue= *pixPtr=
e.g. 35654414.

Gerd Simons

"Greg McKaskle" wrote in message
news:3A2EF679.DE9F786F@austin.rr.com...
> > within LabView 5.1.1 on Windows NT I try to manipulate an IMAQ image
with a
> > C programme using a CIN (code interface node). In LabView there exists
the
> > function IMAQ GetImagePixelPtr which returns a pointer on a pixel of the
> > image (e.g. imagePtr).
> > I have defined with IMAQ Create an 8 bit image and the applied IMAQ
> > GetImagePixelPtr. The returned value of the pointer (*imagePtr) is a
very
> >
big number (e.g. 35654414) and not as I supposed an 8 bit integer
(something
> > between 0 and 255) which should reflect the brightness of this pixel.
> >
> > Does anyone has an idea how I can get the brightness information of each
> > pixel in C?
> >
>
> Without being really familiar with these functions, from the
> name, I would expect that function to return a Ptr. A ptr to
> the pixel. To get the value of the pixel, dereference the
> ptr. In otherwords, if the ptr variable is pixPtr, then
> pixelValue= *pixPtr;
>
> Greg McKaskle
0 Kudos
Message 3 of 5
(3,213 Views)
"Gerd Simons" wrote in message
news:3a2f4326@pfaff.ethz.ch...
> You are right, the function returns a pointer, in the manual it says a
> pointer on a pixel of the image. What I don't understand is why the
> dereferenced pointer has such a big value, i.e. why pixelValue= *pixPtr=
> e.g. 35654414.
>
> Gerd Simons
>

what is the C prototype of this function? Maybe it is int* AKA
pointer to a C int? (or unsigned int ... etc.)
What are the parameters? X and Y indices?
If just the pointer to the whole array what I suspect not
knowing the function is that it is actually a pointer to
the image array as raw linear byte array in the memory,
and you have to build some useful access functions around it
if you have for example a bit depth
of 8 than a int* isn't
appropriate! Because if it is dereferenced it is actually reading
the number of bytes of an int AKA 4 bytes (assuming 32 bit
ints. Check your system/compiler manual ...)

/jw
0 Kudos
Message 4 of 5
(3,213 Views)
> You are right, the function returns a pointer, in the manual it says a
> pointer on a pixel of the image. What I don't understand is why the
> dereferenced pointer has such a big value, i.e. why pixelValue= *pixPtr=
> e.g. 35654414.

What is the variable type that you are dereferencing?
If pixPtr is a long*, then pixelValue= *pixPtr will use
four bytes to determine the pixelValue. If pixPtr is
a short*, then it will use two bytes, if pixPtr is a
char*, then it will use only one byte, and this seems
to be what you are expecting.

So, it sounds like you either need to declare pixPtr
to be a char*, int8*, uInt8*, or some other type that
points to only one byte. Or, you can cast it like
pixelValue= *(char*)pixPtr;

Aren't pointers fun?
Greg McKaskle
0 Kudos
Message 5 of 5
(3,213 Views)