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;
fontSize=15;
structBoundaries = bwboundaries(binaryImage);
xy=structBoundaries{1};
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]);

 채택된 답변

Walter Roberson
Walter Roberson 2013년 1월 5일

1 개 추천

The binary image is sized for one bitplane, so
outerImage(~binaryImage)
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;

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Get Started with Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by