From: Joseph on
Hi, I am using function 'contour' to display my image segmentation result on a grayscale CT image. Then I noticed that the background image looks brighter after the contour is displayed on the screen.

This is my code:

imagesc(imgslice);colormap(gray); %imageslice is a 2D double-format image

hold on;contour(imgbw,'Color','r');%imgbw is the segmentation binary mask image
hold off;



I am preparing to present the original image and the contour image so this inconsistency may be attacked by the examiners.


I am hoping someone here could help me! Thanks a lot!!
From: ImageAnalyst on
That is not at all how I'd do it. Assuming imgbw is just a regular
binary image, I'd get the boundaries using bwboundaries, then use
plot() to plot them over the image. Like this (taken from my image
segmentation demo at http://www.mathworks.com/matlabcentral/fileexchange/25157):

% bwboundaries() returns a cell array, where each cell contains the
row/column coordinates for an object in the image.
% Plot the borders of all the coins on the original grayscale image
using the coordinates returned by bwboundaries.
subplot(3, 3, 6);
imagesc(originalImage);
title('Outlines, from bwboundaries()');
axis square;
hold on;
boundaries = bwboundaries(binaryImage);
numberOfBoundaries = size(boundaries);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
hold off;

From: Gang on
Hi Image Analyst,

thanks for your help. my problem is solved.




On Aug 12, 11:15 am, ImageAnalyst <imageanal...(a)mailinator.com> wrote:
> That is not at all how I'd do it.  Assuming imgbw is just a regular
> binary image, I'd get the boundaries using bwboundaries, then use
> plot() to plot them over the image.  Like this (taken from my image
> segmentation demo athttp://www.mathworks.com/matlabcentral/fileexchange/25157):
>
> % bwboundaries() returns a cell array, where each cell contains the
> row/column coordinates for an object in the image.
> % Plot the borders of all the coins on the original grayscale image
> using the coordinates returned by bwboundaries.
> subplot(3, 3, 6);
> imagesc(originalImage);
> title('Outlines, from bwboundaries()');
> axis square;
> hold on;
> boundaries = bwboundaries(binaryImage);
> numberOfBoundaries = size(boundaries);
> for k = 1 : numberOfBoundaries
>         thisBoundary = boundaries{k};
>         plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
> end
> hold off;