extract leaf from background

4 ビュー (過去 30 日間)
Sajitha K.N.
Sajitha K.N. 2020 年 1 月 22 日
回答済み: Selva Karna 2020 年 1 月 22 日
AppleCedarRust3.JPG
I have a dataset of images like this I want to covert its background to white.Or extract only leaf from this image. Please somebody help.

回答 (1 件)

Selva Karna
Selva Karna 2020 年 1 月 22 日
clc
clear all;
close all;
rgb=imread('your image');
%% Check second layer high intensity
%% Then set thresholf you got foreground
gray=rgb2gray(rgb);
bw=gray<thresold; %% second layer highe intensity value
bw2=imdilate(bw,'disk',2,2);
%% find the hols from above bw2
hls=find(bw2==0);
msk=zerso(h,w);
msk(hls)=255;
r=rgb(:,:,1);
g=rgb(:,:,2);
b=rgb(:,:,3);
r(hls)=0;
g(hls)=0;
b(hls)=0;
forground_image=cat(3,r,g,b);

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by