Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

extract an image from a larger image

I snap an 24bit RGB color image size: 748 x 566 and I would like to remove the border and extract a smaller (still need color) image 10 pixels smaller from each side. result size ~ 728 x 546. How do I tell the extract VI or Resample VI to do this.
Start from the left corner go in 10 pixel x direction and 10 pixels y direction...
0 Kudos
Message 1 of 8
(4,021 Views)
Use IMAQ Extract, and create a constant for the optional rectangle. This should be an array with four elements, with the values of 10,10,738,556. The larger values may need to be reduced by one.

Bruce
Bruce Ammons
Ammons Engineering
Message 2 of 8
(4,021 Views)
Thanks Bruce,
I vote for you the "best support member" of the year.
My next question is also related to Vision.
1. I have a flow diagram, begin with
IMAQ create,
Specify a rectangle 748 X 566 area
Get pixel pointer (function: map pixel pointer)
IMAQ imgsnap 'now I have an image in memory
insert IMAQ extract here
IMAQ ColorImagetoArray
IMAQ Flatten Pixmap
IMAQ Draw Flatten Pixmap
'I have to do the above 3 to draw to screen
0 Kudos
Message 3 of 8
(4,021 Views)
I don't know what your question is, but I can make a couple of comments:

You don't need to use "Get Pixel Pointer" - that is only used for external routines.

If you don't have the Vision toolkit, you won't have the Extract routine. You will need to specify the optional rectangle in ColorImageToArray.

If you do have the Vision toolkit, you should use the WindDraw functions instead. They are much faster than picture controls.

Take a look at all the examples. That should help you use the functions.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 8
(4,021 Views)
Your answer is correct, I'd like to have more speed.
I have Vision toolkit, Sony DXC-390 PAL and PCI-1409.
I use the BNC Connector(NOT the other connector).
To Snap image:
1. IMAQ Init, stillcolor Mode, channel 0, Color Repre
2. IMAQ Create (RGB, border=2)
3. To define my image size.
I use the CIN from IMAQ rectToCoor.VI.
(new image, x res=748; y res=566; output:image)
4. call IMAQ Getpixel ptr (input:image, map pixel ptr,
output:pixel ptr out, linewidth)
I assume this is a pointer in memory for snapping
5. call low level ImgSnap area(in: image,sessionID,
buffer= pixel ptr out,top, left, bottom, right,
rowbytes = linewidth)
'output assuming image is in memory area
6. ColorimagetoArra
y
7. Flatten pixmap
8. Draw flatten pixmap
9. IMAQ write jpg file.
Please comment on my step, I take about two seconds per image, that is slooow.
0 Kudos
Message 5 of 8
(4,021 Views)
StillColor is the reason you can only acquire a few images per second. If you switch to grayscale, you will be able to acquire images much faster. Saving each image will slow you down quite a bit also.

Since you have the Vision toolkit, you should be able to display at the full acquisition rate.

Look at the IMAQ examples that demonstrate how to use Grab to continuously acquire images and display them using WindDraw. This is the fastest and most efficient method. The only change you would need to make is setting your optional rectangle for the limits of the image. This could also be done in MAX.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 6 of 8
(4,021 Views)
Thank you Bruce, I have learned a lot from you.
My goal is to test LCD about 6 inch diagonal,
I am thinking about display a one color (blue, red,green) screen and test each individual pixel with a +/- 10%tolerance value.

Is this the correct method?
0 Kudos
Message 7 of 8
(4,021 Views)
I would need to know much more about the system before making any recommendations.

One key issue is to make sure your image resolution is significantly larger than your LCD resolution if you need to resolve each pixel in the LCD.

You might want to look at some of NI's test routines. They have a package for testing displays, which might do everything you need and save you a lot of development.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 8 of 8
(4,021 Views)