Re: selecting a region of interest based on greyscale J value
- From: "Image Analyst" <imageanalyst@xxxxxxxxxxxxxx>
- Date: Sat, 3 Jan 2009 16:12:02 +0000 (UTC)
mattyjbennett <mattyjbennett@xxxxxxxxxxxxxx> wrote in message <fdcdaa56-1f27-430e-9db3-07ff92b06080@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
Hi all,Matthew:
I'm afraid i'm new to this, but making progress. I'm making a module
in Matlab 7.5 which is able to read an image as an RGB array, convert
to greyscale (J data) and have toyed with code to be able to report
back the J value stored at x,y coordinate, do doing ok so far.
The next step however is causing me some headache:
I want to open up a colour image in the viewer, select a few pixels
with the mouse and from their J values create a region of interest.
(similar to the 'magic wand' tool in Photoshop). I then want to save
the x,y coords of these pixels and also for each of the selected (will
probably only seelct about 5) export the pixel colour data and J value
to a database table, so:
From my image,
1, export each selected pixel (by the user) into a table, storing RGB
and J (greyscale) value for each. This dataset stored with a name
(e.g. actor 1's hat) which can be retrieved by another module later
on.
2. from the selected pixels and (I suspect using block operation /
nearest neighbour) determine all of the pixels which have similar J
values that are nearby and mark them out in a new array.
The intention is to the affect a new image stored as an I (RGB matrix)
which is in fact a greyscale image (no colour) but saved as a BMP or
JPG in RGB mode as I want to add colour to the image later on. (more
on that another time)
I realise that there could be a lot of similar data here so am only
interested in modal data (e.g. if there are lots of J data: 101,
132,133,133,139,133,133,101,101,102) I really only need to store:
101,133,139
I hope that makes sense. I'll send what I've done so far on the
initial coord selection below, but if any kind soul can help I'd be
grateful.
Best regards,
Matthew Bennett
For #1, you might want to take a look at the roipoly and roipolyold functions. Then use the poly2mask function to convert the polygon into a logical image which you can multiply by your original image to get just the drawn pixels. Crop the image beforehand if you want (there might be an imcrop command that you can use with the max and min x and y values derived from the roipoly output). Then you can save with either an imwrite() function or the save() function.
For #2, just use thresholding, something like:
toleranceGLs = 5;
differenceImage = abs(originalImage - meanGrayLevel);
inRangeImage = (differenceImage < toleranceGLs);
Use find() if you want actual row and column positions of the "in range" pixels.
.
- Follow-Ups:
- Re: selecting a region of interest based on greyscale J value
- From: mattyjbennett
- Re: selecting a region of interest based on greyscale J value
- From: mattyjbennett
- Re: selecting a region of interest based on greyscale J value
- References:
- selecting a region of interest based on greyscale J value
- From: mattyjbennett
- selecting a region of interest based on greyscale J value
- Prev by Date: Re: (plx, help) how to do image.tif recognition and extraction
- Next by Date: Re: curious problem with sparse matrices that have explicit "0" entries.....
- Previous by thread: Re: selecting a region of interest based on greyscale J value
- Next by thread: Re: selecting a region of interest based on greyscale J value
- Index(es):
Relevant Pages
|
Loading