MATLAB Answers


how to get enhanced segmented image

Asked by Elysi Cochin on 5 Jan 2013

i used roipolyold to select the region i want.... now when i use the below code i get the segmented image and the unwanted image in blue color.... can i change the blue color to black so that i get the perfect segmented output....

    ROI = ROIPOLYOLD(inputImage);
    binaryImage = ROI;
    structBoundaries = bwboundaries(binaryImage);
    x = xy(:, 2); 
    y = xy(:, 1); 
    outerImage = inputImage;
    outerImage(~binaryImage) = 0;
    leftColumn = min(x);
    rightColumn = max(x);
    topLine = min(y);
    bottomLine = max(y);
    width = rightColumn - leftColumn + 1;
    height = bottomLine - topLine + 1;
    segmentedImage = imcrop(outerImage, [leftColumn, topLine, width, height]);



No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 5 Jan 2013
 Accepted answer

The binary image is sized for one bitplane, so


is going to only affect at most the first bitplane of outerImage. You want to have it affect all the bitplanes.

outerImage(repmat(~binaryImage, [1,1, size(outerImage,3))) = 0;

  1 Comment

Join the 15-year community celebration.

Play games and win prizes!

Learn more
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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!