Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Help on image processing

Subject: Help on image processing

From: rustyraj 18

Date: 1 Jul, 2010 18:17:07

Message: 1 of 5

I need to blacken out a specified region of interest of an image. the region can be any closed shape.I need to set the pixel value inside the region to zero. how can i do that.

Please help me.i m in urgent need.

With regards
rustyraj

Subject: Help on image processing

From: Sean

Date: 1 Jul, 2010 18:46:04

Message: 2 of 5

"rustyraj 18" <rustyraj18@gmail.com> wrote in message <i0im32$ooo$1@fred.mathworks.com>...
> I need to blacken out a specified region of interest of an image. the region can be any closed shape.I need to set the pixel value inside the region to zero. how can i do that.
>
> Please help me.i m in urgent need.
>
> With regards
> rustyraj

I(region) = 0;

Subject: Help on image processing

From: rustyraj 18

Date: 1 Jul, 2010 19:01:20

Message: 3 of 5

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i0inpc$fqn$1@fred.mathworks.com>...
> "rustyraj 18" <rustyraj18@gmail.com> wrote in message <i0im32$ooo$1@fred.mathworks.com>...
> > I need to blacken out a specified region of interest of an image. the region can be any closed shape.I need to set the pixel value inside the region to zero. how can i do that.
> >
> > Please help me.i m in urgent need.
> >
> > With regards
> > rustyraj
>
> I(region) = 0;


How to select the region from the image??

Subject: Help on image processing

From: Sean

Date: 1 Jul, 2010 19:22:05

Message: 4 of 5

"rustyraj 18" <rustyraj18@gmail.com> wrote in message <i0iom0$e5n$1@fred.mathworks.com>...
> "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i0inpc$fqn$1@fred.mathworks.com>...
> > "rustyraj 18" <rustyraj18@gmail.com> wrote in message <i0im32$ooo$1@fred.mathworks.com>...
> > > I need to blacken out a specified region of interest of an image. the region can be any closed shape.I need to set the pixel value inside the region to zero. how can i do that.
> > >
> > > Please help me.i m in urgent need.
> > >
> > > With regards
> > > rustyraj
> >
> > I(region) = 0;
>
>
> How to select the region from the image??

I don't know; nor will any other CSSMer. It's not our homework assignment.

Subject: Help on image processing

From: ImageAnalyst

Date: 1 Jul, 2010 19:46:57

Message: 5 of 5

Look at this demo. Adapt as needed:

% Change the current folder to the folder of this m-file.
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;

% Read in standard MATLAB gray scale demo image.
grayImage = imread('cameraman.tif');
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
message = sprintf('Left click and hold to begin drawing.\nLift mouse
button to finish');
uiwait(msgbox(message));
hFH = imfreehand();

% Create a binary image ("mask") from the ROI object.
binaryImage = hFH.createMask();
% Display the freehand mask.
subplot(2, 2, 2);
imshow(binaryImage);
title('Binary mask of the region', 'FontSize', fontSize);

% Get coordinates of the boundary of the freehand drawn region.
structBoundaries = bwboundaries(binaryImage);
xy=structBoundaries{1}; % Get n by 2 array of x,y coordinates.
x = xy(:, 2); % Columns.
y = xy(:, 1); % Rows.
subplot(2, 2, 1); % Plot over original image.
hold on; % Don't blow away the image.
plot(x, y, 'LineWidth', 2);

% Burn line into image by setting it to 255 wherever the mask is true.
burnedImage = grayImage;
burnedImage(binaryImage) = 255;
% Display the image with the mask "burned in."
subplot(2, 2, 3);
imshow(burnedImage);
title('New image with mask burned into image', 'FontSize', fontSize);

% Mask the image and display it.
% Will keep only the part of the image that's inside the mask, zero
outside mask.
maskedImage = grayImage;
maskedImage(~binaryImage) = 0;
subplot(2, 2, 4);
imshow(maskedImage);
title('Masked Image', 'FontSize', fontSize);

% Calculate the mean
meanGL = mean(maskedImage(binaryImage));
message = sprintf('Mean value within drawn area = %.3f', meanGL);
msgbox(message);

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us