i had apply morphological processing on an image that is close. i want to color the white part of the binary image that is processed to green. how can i do that

1 回表示 (過去 30 日間)
clear all;
close all;
global I2;
I1 = imread('imm2.jpg');
I2 = imresize(I1,.5);
img_gray=255-(0.3*I2(:,:,1)+0.6*I2(:,:,2)+0.11*I2(:,:,3));
level=graythresh(I2);
BW1=im2bw(I2,level);
BW = imcomplement(BW1);
se=strel('square',11);
close_img=imclose(BW,se);
the image is:
  2 件のコメント
Image Analyst
Image Analyst 2018 年 6 月 11 日
Unfortunately you forgot to attach imm2.jpg,
and haven't read this link
iqra toheed
iqra toheed 2018 年 6 月 11 日
編集済み: iqra toheed 2018 年 6 月 11 日
when you run will this code. the image variable named as BW1 make an inverted binary image.

サインインしてコメントする。

採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 6 月 11 日
% Disclosure: Help from stackoverflow.com
clc;
clear all;
close all;
global I2;
I1 = imread('imm2.jpg');
I2 = imresize(I1,.5);
img_gray=255-(0.3*I2(:,:,1)+0.6*I2(:,:,2)+0.11*I2(:,:,3));
level=graythresh(I2);
BW1=im2bw(I2,level);
BW= imcomplement(BW1);
se=strel('square',11);
close_img=imclose(BW,se);
color_level= [1 255 1];
color_img=bsxfun(@times,double(close_img),permute(color_level,[1 3 2]));
RGB=uint8(color_img-(color_img==0).*255);
imshow(RGB);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by