Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

export graph as image : resolution issue

GOAL:
create an intensity graph.  locate the centroid of the an object with the highest intensity value.  display coordinates.
 
1: I have created a graph, where there is a single spot of the highest intensity (10, 40).  I am trying to locate this location, not by searching the array for the highest value (which I know is possible), but by using image analysis to find the intensity, then locating the centroid.
 
2: Export the graph, then threshold the image so that only the highest intensity is isolated. 
 
3: When the centroid is located, you can see that the resulting coordinates are different.  I understand that (0,0) on a graph is located at the bottom left hand corner, which is different from the (0,0) on an image which is at the upper right hand corner.  I've also tried to eliminate the excess pixels that were created from the borders of the graph.  Finally after subtracting the borders, my calculated coordinates were (20,106), which are obviously far different from (10,40).
 
QUESTION:
I'm not sure if the if the resolution changed when I exported the image, or whether it is something else.  But I have exported the image at 24-image depth and 100% quality (jpeg).  At this point I'm not able to figure this one out on my own and am seeking help and advice.
 
 
0 Kudos
Message 1 of 11
(5,026 Views)
I attached the wrong picture.  This one should be better
0 Kudos
Message 2 of 11
(5,020 Views)
I'm not sure what is happening.  Could you post a simple VI and your image so that I can take a look at it? Thanks.
 
Christopher W.
Applications Engineer
National Instruments
0 Kudos
Message 3 of 11
(5,004 Views)

The program I attached will do the following...
1. has a 2D of (x,y,z) inputs
2. plots the points
3. interpolates points
4. uses IMAQ functions to locate highest z value
5. calculates location on the image
6. attempts to convert the location, to a location that is relative to the graph plot.

Right now, I'm having issues converting back to (x,y) coordinates on the graph plot.  I tried to comment the program, but if you still have additional questions, don't hesitate to ask.

0 Kudos
Message 4 of 11
(4,992 Views)
Can you attach the binary interpolation.vi?
0 Kudos
Message 5 of 11
(4,983 Views)
I uploaded a new version of the program that i was working on.  It might be a little clearer what I'm trying to accomplish, as well as some addtional progress.
 
The new library should include everything, including the bilinear interpolation.  Right now I've gotten to the point where I'm trying to convert back into the latitude/longitude coordinate system (opposed to the image, or graph coordinate system).  I'm trying to better understand the interpolation and the 'averaging', so I can achieve a conversion, back into real world coordinates.
 
Thanks for the help.
0 Kudos
Message 6 of 11
(4,970 Views)
So it looks as though you have an intensity graph that you are trying to convert to an image so that you can use IMAQ with it.  You may have already considered this but your problem may have to do with different scaling for the two data types.  The image data type is broken up into pixels while the graph isn't.  It also looks as though they are different sizes (the graph looks smaller than the image).
 
Christopher W.
Applications Engineer
National Instruments
0 Kudos
Message 7 of 11
(4,966 Views)
Right, I've realized that when I capture the image, the image is including the borders (whether they are, or aren't transparent).  I found that the top border is 50px, the left border is 20px, the right is 80px, and the bottom is 5px.  Because of these added borders, there is a bit of an added offset when IMAQ locates the intensity.  Instead of seeing something like (20,160), I'll get (27.8966, 200.207).  So keeping in mind that the (0,0) for an image is located in the upper left, and (0,0) for a graph is located in the bottom left, I've managed to get to get close to converting from an image domain to a graph domain by attempting to remove this offset.  Here is the equation that i'm currently using... it's still not perfect.

(x.img - 20px) * (x.min.grph / grph_size_only) = x.grph
 
x.min.graph: is the minimum x-value of the graph range.
grph_size_only: is the size of the IMAQ captured graph, after the borders have been deleted.
* These two values create a resolution conversion constant.
 
My main issue at the moment is trying to convert from the image cooridnate domain, back to the graph coordinate domain (so things haven't changed much).  But I have realized that in the graph domain, the x and y-axis are defined by 400px resolution; in the image domain... after deleting the extra borders, the x/y-axis are both 250px wide.  But I'm having trouble restoring the coordinate values the state before it reaches interpolation.  If you have any suggestions how I might go about (de-interpolating) the image, if there is such an expression, then that might be helpful.
 
I attached a revised version of my program as well.
 
0 Kudos
Message 8 of 11
(4,942 Views)
Honestly, I'm not sure where to go from here.  You've gotten a lot closer than I could have.  I've never heard of anyone taking the image data from an intensity graph, writing it to a JPEG, opening the JPEG with IMAQ, and converting it back to the original graph coordinates.  The conversion is complicated and I would hope that it would not be necessary.  What is the overall goal of doing this?  I wonder if there is a different approach you can take.
 
Christopher W.
0 Kudos
Message 9 of 11
(4,880 Views)
I realize that this may seem like a round-about way to sovle to the problem, but the entire reason for exporting and importing the image, was to take advantage of the centroid function.  when the area of interest (areas of high intensity that are large and oddly shaped), I wanted to use the centroid function to simplify this calculation.
 
Although I've gotten close to completing a full conversion back into the coordinate domain, there is still a bit of error.  The algorithms used to convert back into the coordinate domain are based mainly off of the averaging and interpolation that is applied to the sampled input.  The interpolation is important because it helps to recreate the sampled area.  Rather than seeing two points of high intensity, the interpolation will create an entire region, which is defined by the value.
 
The image below demonstrates the 1. sampling of coordinates, 2. interpolation of points, 3. and locating of the source.  This image in particular demonstrates the case where the source is not one of the points that are sampled (unlike the case in the program).  If anyone has any better ideas how I might accomplish such a task, I'm open to suggestions.  Hopefully I didn't just repeat things that I mentioned in my previous posts.
0 Kudos
Message 10 of 11
(4,860 Views)