필터 지우기
필터 지우기

change color "bwperim"

조회 수: 9 (최근 30일)
Rahma Yeni
Rahma Yeni 2012년 4월 16일
댓글: Markus Kokot 2020년 12월 29일
Hello... I got this code form Help MATLAB, in "Detecting a Cell Using Image Segmentation"
BWoutline = bwperim(BWfinal);
Segout = I;
Segout(BWoutline) = 255;
The edge color of that picture is white.. Is possible change the color to another color..?? Thank you.. ^^

채택된 답변

Walter Roberson
Walter Roberson 2012년 4월 16일
You are working with gray-scale images at present. In order to change the edge color you would have to convert the gray-scale to color.
For example,
SegoutR = I;
SegoutG = I;
SegoutB = I;
%now set yellow, [255 255 0]
SegoutR(BWoutline) = 255;
SegoutG(BWoutline) = 255;
SegoutB(BWoutline) = 0;
SegoutRGB = cat(3, SegoutR, SegoutG, SegoutB);
  댓글 수: 4
Rahma Yeni
Rahma Yeni 2012년 4월 17일
Thank you Image Analyst.. ^^
Markus Kokot
Markus Kokot 2020년 12월 29일
for me it does not work - which picuture name would than be in the end to show in this example ?
and is "I" the imread picture from your beginning which is not in greyscale?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Spandan Tiwari
Spandan Tiwari 2012년 4월 16일
You can change the color by filling the perimeter pixels with a color value instead of a scalar 255. One possible way to do this is as follows:
% First make a RGB image for display:
Segout = repmat(I, [1 1 3]);
% Find indices of the boundary pixels
outline_idx = find(BWoutline);
% Find the indices to fill in the RGB image
Segout_idx = [outline_idx; numel(BWoutline)+outline_idx; ... 2*numel(BWoutline)+outline_idx];
% Select the color (RGB triplet) for the boundary. I choose red.
colorValue = [255; 0; 0]; % For green [0 255 0]
% Prepare a color vector to fill in the RGB image
outline_fill_values = kron(colorValue,ones(size(outline_idx)));
% Fill the RGB image with the color value
Segout(Segout_idx) = outline_fill_values;
% Display the RGB image
figure, imshow(Segout), title('outlined original image');

태그

Community Treasure Hunt

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

Start Hunting!

Translated by