Tracing boundary in RGB image

4 ビュー (過去 30 日間)
Busy Bee
Busy Bee 2019 年 5 月 7 日
回答済み: Josh 2019 年 5 月 10 日
I have a TIFF image that i have attached with this question (Picture1). I could not attach the TIFF format hence attached a JPEG format.
Picture1.jpg
It is a random image. I want to convert it into boundary image, i.e. the different color parts are represented by just a boundary as shown in Picture 2. Picture2.png
Any help would be appreciated. I have MATLAB 2015a. I have tried using visboundaries but I could not convert my TIFF image into binary.

回答 (1 件)

Josh
Josh 2019 年 5 月 10 日
You just want the outlines of the colored regions stored in another image, right?
You can use the gradient function:
% Convert image to double (gradients are always returned as double arrays)
J = im2double(I);
% Loop through color channels (assuming original image is stored in I)
for i = 1 : 3
G(:,:,i) = imgradient(I(:,:,i));
end
% Convert the gradient to grayscale and flip black and white
E = 1 - rgb2gray(G);

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by