how can i multiply an edged image to original one and put the edge pixela = 0?

i want to change the background of an image with the means value of forground in order to emphasize on the border pixels and put them zero . for this purpose first of all i Calculated borders and then i need to multiply border image to original one and the put these pixels zeros. but i have problem with the size and class of these image. borde image is logical and original image is of class uint8.It is noteworthy that i change them to uint8 , i dont have errors but the figure of this multiply dosent show any thing. please help me

 Accepted Answer

So you have a binary (logical) edge image. Now you want to change the background of the gray scale image to either the mean gray level of the foreground image, or to zero -- I can't figure out which since you've said both. So that's one request, apparently. To do that you need to segment your image into foreground and background and I'll assume you know how to do that, and I'll assume that you have a binary mask image, foregroundMask. Then
maskedImage = grayImage; % Initialize
% Get the mean of only the foreground pixels.
meanOfForeground = mean(grayImage(foregroundMask));
maskedImage(~foregroundMask) = meanOfForeground; % Set background to mean of the foreground.
Now for the second thing you asked, to set the border pixels to zero, do this:
outlinedImage = grayImage; % Initialize
outlinedImage(edgeImage) = 0; % Set to zero where the border pixels are.
Does that answer both your questions?

1 Comment

Dear Image Analyst i am so grateful you .your code was a great help to me .this was just something I wanted . thank you .

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!