Re: image analysis question



On May 5, 5:21 pm, ImageAnalyst <imageanal...@xxxxxxxxxxxxxx> wrote:
On May 5, 2:39 pm, ms <silvert...@xxxxxxxxx> wrote:





On May 4, 6:57 am, "Image Analyst" <imageanal...@xxxxxxxxxxxxxx>
wrote:

ms:
For each region, you get the mean.  You define the regions
by whatever means you want.  For me, I have a series of
boxes where I keep track of topLine, bottomLine,
leftColumn, rightColumn for every box.  These 4 numbers are
put into an array so that I have an N by 2 array where N is
the number of calibration regions in the image.  Now, you
take the mean of each region.  If I recall correctly it's
something like
for k = 1 : numberOfRegions
  x1 = boxLocations(k).leftColumn;
  x2 = boxLocations(k).rightColumn ;
  y1 = boxLocations(k).topLine;
  y2 = boxLocations(k).bottomLine;
  meanOfRegion(k) = mean2(calibrationImage(y1:y2, x1:x2));
end
I have a GUI that lets people move the boxes around and
save their locations, as well as a listbox of calibration
images that they can read in.
Now you make up two arrays of N by 1.  The first array
(polyfit's "X" array) is the mean gray levels of the
regions, for example 50 gray levels, 100 gray levels and so
on.  The second array (polyfit's "Y" array) is the actual
real world pressures that you used for the region, for
example 100 grams/m^2, 200 grams/m^2 and so on.  for those
regions.  
actualPressures = [100 200 300 and so on];
Feed these both into polyfit (going by memory here since I
don't have MATLAB open at the moment)
orderOfPolynomial = 2;
coefficients = polyfit(meanOfRegions, actualPressures,
orderOfPolynomial);

and you get out an array of coefficients that tell you how
to put in a gray level and get out a pressure.  Now you're
almost done.  Next take an image, say the calibration image
or any test image with unknown pressures, and get an output
image that is the estimated calibrated pressure image.  For
example
estimatedPressures = coefficient(0) + coefficient(1) *
testImage + coefficient(2) * (testImage .* testImage);
Now you're done and you can go ahead and process that image
in any way that you like and you will be working with real
world units.
These seem like pretty explicit instructions so hopefully
they will be enough for you to use, but write back if you
still have questions.
Best wishes,
ImageAnalyst
P.S. Pay attention to what I said in the earlier message
about getting the monochrome image from the color image
(don't do what you said, unless there is no difference in
contrast, which I'm pretty sure is not the case, and you're
doing it to reduce the noise).- Hide quoted text -

You have been extremely helpful!  Instead of simply using rgb2gray, I
tried using image(:,:,2)%this was to look at the blue channel (That is
correct, right?).  I actually looked at 1,2,3 and noticed that the
blue channel was the best out of the three.  Is there any disadvantage
to this...instead of using rgb2gray (well, that is another story)?
Back to "selecting the regions".  I understand what to do with the
information once each mean is determined for each of the different
regions (l think 4 would work in my case)...that is, I would know how
to use the polyfit function to create my calibration after both
intesity and pressure are both determined.  What I don't understand at
this point is how you are determining your roi?  You sent the code:

for k = 1 : numberOfRegions
  x1 = boxLocations(k).leftColumn;
  x2 = boxLocations(k).rightColumn ;
  y1 = boxLocations(k).topLine;
  y2 = boxLocations(k).bottomLine;
  meanOfRegion(k) = mean2(calibrationImage(y1:y2, x1:x2));
end

(I would then take mean(meanOfRegion) to give me the overall
calibration value for this particular image, correct?...I would then
perform this for each of the other images to be used for calibration.)

say numberOfRegions = 4;

what are the variables within the loop, such as
"boxLocations(k).leftColumn"?  I am guessing that these are the x,y
values given by your box used to select a region of interest?  I was
also unfamiliary with the "." seperating the two...is this a
particular format?

I tried using the roipoly function in matlab to select an area, but it
was somewhat difficult (not an exact box) to use accurately.  Is there
a function that will display a box on the image, move it around, and
resize the box size (I may be asking too much!)?  Or is this type of
code simple enough to create?

Image Analyst, you have been a terrific help.  I thought my post was
going to be ignored or minimal input.  I hope I can contribute as you
have some day!- Hide quoted text -

- Show quoted text -

---------------------------------------------------------------------------­-------
ms:
No, you misunderstand parts of it.  The variables in the loop such as
boxLocations(k).leftColumn are the lines and columns defining the
edges of the box.  boxLocations is an array so that if you had 4
boxes, you would have 4 boxLocations's.  boxLocations is a "structure"
which means that I can call the fields of the structure virtually
anything I want.  Look up "structure" in the help file - it's a type
of variable.  Sure, I could have defined an integer array of
boxLocations(4,4) where boxLocations(1,1) would be the left column,
boxLocations(1,2) would be the right column, boxLocations(1,3) would
be the top line, and boxLocations(1,4) would be the bottom line (all
for box #1, and similarly for the other boxes), but I chose to use a
structure instead of an integer array because the structure allows me
to give descriptive names which make the code much more readable.  The
dot in between the structure name and it's field is what separates the
structure object from it's fields - same as any other language, it's
pretty standard.

Now, if I had 4 regions, I certainly would not average them together
like you said except in one very special case: where all your pressure
regions in your image represent the same pressure.  For example, you
have one image with 4 regions and all 4 regions represent 100 grams
per square meter (gsm), and maybe you have another image where you
have 4 regions that are all 200 gsm.  Is that what you have?  In that
case, you could average them together.  What I was assuming was that
you had only one calibration image and that image had serveral regions
all representing DIFFERENT pressures.  In that case you can't average
them together or else you won't have any calibration at all.

Other notes:
The blue image is image(:,:,3) not image(:,:,2)
I don't know of any MATLAB function to have you draw a box.  That
would be a nice additional utility.  Since MATLAB seems to lack that,
that's why I wrote my own code where I load up the corners of the box
into x and y arrays and call plot(x,y).  You can move the boxes by
clicking in the image or nudging them with scroll bars.
Using RGB2gray does a weighted average of the color channels.  However
if one channel is no good, like your red channel which has little
information in it, then you're averaging in something that will reduce
your precision.  So obviously you don't want to do that.  Averaging
will reduce noise (this is a good thing) so if both your green and
blue channels look pretty much the same, you can average just those
two together to reduce your noise and maintain precision.  Often in
digital images the blue channel looks pretty noisy.  If that is your
case, don't use it as it will be worse than using the green channel
only.  So average the green and blue only if both the signal and the
noise look about the same in each channel, otherwise just take the one
single best channel, whichever channel that happens to be.
Regards,
ImageAnalyst- Hide quoted text -

- Show quoted text -

Image Analyst,
I do have multiple images in which the entire area should be
representative of the load applied; however; there is some differences
near the edges(slightly lighter than most of the image). The image is
a circle that should be representative of the load applied, and I am
breaking this up into 4 different parts (like quadrants of a pie),
taking the average of each quadrant, then taking the overall average.
I would then do this for all 10 different loads. I would then plug
all the values to use polyfit and get a calibration curve. The images
to be used at a later date will likely have un-uniform patterns and
will need to deal with that when that time comes.

You were correct, the blue channel (:,:,3) was a noisy channel
compared to the green (at least visually to my naked eye...is there a
way to quantify this?). As for the structures, it looks like a very
nice way to organize data...but will take some getting used to...I
only use matrix arrays! I tried averaging the two channels, but kept
having problems as they are in uint8 format. So I would have green
with an intesity of 180 and blue 200, and when I would add them and
divide by 2 the answer would always be 128 (255/2=127.5...I guess it
rounds up). gb = ((image(:,:,2)+image(:,:,2))/2). There must be a
better way?

As for the box...and being able to nudge it and move it...I was unable
to do so when I used the plot(x,y) function. I plotted the image
(green channel only). created an array for x and y (x=[1 1 10 10 1],
y=[1 10 10 1 1]). I then plotted them over the image (plot(x,y)) and
a blue box appeared in the upper left corner. I was, however, unable
to move the box.

Thanks again!
.



Relevant Pages

  • Re: image analysis question
    ... boxes where I keep track of topLine, bottomLine, ... put into an array so that I have an N by 2 array where N is ... the number of calibration regions in the image. ... blue channel was the best out of the three. ...
    (comp.soft-sys.matlab)
  • Re: image analysis question
    ... put into an array so that I have an N by 2 array where N is ... the number of calibration regions in the image. ... blue channel was the best out of the three. ... sensor gives a variety of signals with the signal being more ...
    (comp.soft-sys.matlab)
  • Re: Digital switch over discussion on R4 midday today(Tuesday 16Oct)
    ... Some boxes will retain the first, say, BBC1 they find and put ... and where to find the channel information anyway. ... Reception was from the Emley Moor ... you can receive from two transmitters, Emley Moor as before and now Belmont ...
    (uk.tech.digital-tv)
  • RE: Question on chat message
    ... Still it is sending message to both channel ... quoting an array would seem to make it in scalar context and you ... likley will just get teh number of elements in it instead of the message ... E-mail transmission cannot be guaranteed to be secure or error-free ...
    (perl.beginners)
  • Re: SQL Server 2000 Performance - 10K vs. 15K
    ... Not a lot slower, but still slower -- and you know ... Log files and data files on separate raid ... OS and Log array is RAID 1 on channel 0, ...
    (microsoft.public.sqlserver.setup)