Main Page | Report this Page
 
   
Science Forum Index  »  Image Processing Forum  »  RGB ROI Mask...
Page 1 of 1    
Author Message
Ponch...
Posted: Fri Jun 27, 2008 12:56 am
Guest
Hi,

I am trying to load an image, create a region of interest which is not
rectangular, create a mask of this area for me to then do some basic
processing on it.
In the selected region i want to subtract the blue band from the red,
and then plot a contour of a various level from that image.

However i am stuck trying to apply the mask. I have the following so
far;

I=imread ('plan.jpg');
mask=roi2poly;

rbI=double(I(:,:,1))-double(I(:,:,3));
contour(rbI,[0 0]);

What i am not sure on is how to apply the mask to the image as a
whole, if i need to use the find command, if so how?

Any suggestions would be very helpful.

Cheers
Ponch
ImageAnalyst...
Posted: Fri Jun 27, 2008 1:21 am
Guest
On Jun 27, 6:56 am, Ponch <timpo... at (no spam) gmail.com> wrote:
Quote:
Hi,

I am trying to load an image, create a region of interest which is not
rectangular, create a mask of this area for me to then do some basic
processing on it.
In the selected region i want to subtract the blue band from the red,
and then plot a contour of a various level from that image.

However i am stuck trying to apply the mask. I have the following so
far;

I=imread ('plan.jpg');
mask=roi2poly;

rbI=double(I(:,:,1))-double(I(:,:,3));
contour(rbI,[0 0]);

What i am not sure on is how to apply the mask to the image as a
whole, if i need to use the find command, if so how?

Any suggestions would be very helpful.

Cheers
Ponch

------------------------------------------
(This is MATLAB). You need to dot-multiply your mask by your image:
maskedImage = rbI .* mask;

Regards,
ImageAnalyst
Ponch...
Posted: Fri Jun 27, 2008 1:44 am
Guest
On Jun 27, 12:21 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:
Quote:
On Jun 27, 6:56 am, Ponch <timpo... at (no spam) gmail.com> wrote:



Hi,

I am trying to load an image, create a region of interest which is not
rectangular, create a mask of this area for me to then do some basic
processing on it.
In the selected region i want to subtract the blue band from the red,
and then plot a contour of a various level from that image.

However i am stuck trying to apply the mask. I have the following so
far;

I=imread ('plan.jpg');
mask=roi2poly;

rbI=double(I(:,:,1))-double(I(:,:,3));
contour(rbI,[0 0]);

What i am not sure on is how to apply the mask to the image as a
whole, if i need to use the find command, if so how?

Any suggestions would be very helpful.

Cheers
Ponch

------------------------------------------
(This is MATLAB).  You need to dot-multiply your mask by your image:
maskedImage = rbI .* mask;

Regards,
ImageAnalyst

Hi,

Thanks,
If i do this the new image is a binary representation of the red-blue
band. I really want to be able to plot the image as a pcolor to see
the different conoturs before choosing which to select for a contour
plot.
So i guess i want to use the mask in the same way as a croping the
image would allow, however it seems you can only crop in rectangles
with Matlab?

Thanks
ImageAnalyst...
Posted: Fri Jun 27, 2008 5:48 am
Guest
On Jun 27, 7:44 am, Ponch <timpo... at (no spam) gmail.com> wrote:
Quote:
On Jun 27, 12:21 pm, ImageAnalyst <imageanal... at (no spam) mailinator.com> wrote:





On Jun 27, 6:56 am, Ponch <timpo... at (no spam) gmail.com> wrote:

Hi,

I am trying to load an image, create a region of interest which is not
rectangular, create a mask of this area for me to then do some basic
processing on it.
In the selected region i want to subtract the blue band from the red,
and then plot a contour of a various level from that image.

However i am stuck trying to apply the mask. I have the following so
far;

I=imread ('plan.jpg');
mask=roi2poly;

rbI=double(I(:,:,1))-double(I(:,:,3));
contour(rbI,[0 0]);

What i am not sure on is how to apply the mask to the image as a
whole, if i need to use the find command, if so how?

Any suggestions would be very helpful.

Cheers
Ponch

------------------------------------------
(This is MATLAB).  You need to dot-multiply your mask by your image:
maskedImage = rbI .* mask;

Regards,
ImageAnalyst

Hi,

Thanks,
If i do this the new image is a binary representation of the red-blue
band. I really want to be able to plot the image as a pcolor to see
the different conoturs before choosing which to select for a contour
plot.
So i guess i want to use the mask in the same way as a croping the
image would allow, however it seems you can only crop in rectangles
with Matlab?

Thanks- Hide quoted text -

- Show quoted text -

Ponch:
Here's some MATLAB code for you:
% We need to convert the type of imgMask to the same data type as
imageArray.
strDataType = class(imageArray);
imgMask = eval([strDataType '(imgMask)']);

% Mask the image
imageArray(:,Smile = imgMask .* imageArray(:,Smile;
% Display image array in a window on the user interface.
axes(handles.axesImage);
imshow(imageArray, []);
If you see any 3D's after the equal signs, ignore them - it's caused
if you use a newreader that's not mime aware.
You can only have rectangular images in MATLAB because it considers an
image as an array (matrix). The area outside of your ROI is just
zeros. This is strictly not true since you can have non-rectangular
images where you have linear arrays storing just non-zero pixel
coordinates and the image values at those coordinates but usually it's
not worth the trouble. You can crop using the roipoly routine, you
just have to scan the coordinates to find the bounding box (x1, x2,
y1, y2) of the polygon, and then use something like
croppedImage = originalImage(y1:y2, x1:x2);
Since this is more of a MATLAB coding question than an image analysis
algorithm question, it probably should have been posted in comp.soft-
sys.matlab.
Regards,
ImageAnalyst
 
Page 1 of 1       All times are GMT - 5 Hours
The time now is Fri Dec 05, 2008 10:23 am