二値化した画像を重ね合わせ等高線図みたいにしたい
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
ある画像をそれぞれのしきい値(例:250、240、230・・・というような)で二値化処理し、
それぞれのしきい値で二値化した画像の白い領域の部分の色を変え(例:250の時赤、240の時青・・・といった感じ)
最後に色変えしたそれぞれのしきい値の二値化画像を重ね合わせて等高線図みたいな物を作りたいのですが
どなたかご教授お願いいたします。(下記のプログラムを改造または回答者様なりの方法でも構いません)
clear all;
close all;
% 各種定義
fig = 0;
for i=7
    %Image Read
    Imgfilename = strcat('./',num2str(i),'.jpg');
    img=imread(Imgfilename);
    gimg=rgb2gray(img);
    BW = 250:5:255;
    BW2 = medfilt2(BW);
    BW3 = imfill(BW2,'holes');
    BW4 = im2uint8(BW3);
    BW_out = BW;
    % Remove portions of the image that touch an outside edge.
    BW_out = imclearborder(BW_out);
    % Fill holes in regions.
    BW_out = imfill(BW_out, 'holes');
    % Filter image based on image properties.
    BW_out = bwpropfilt(BW_out, 'Area', [10 + eps(10), Inf]);
    % Get properties.
    properties = regionprops(BW_out, {'Area'});
    [~,num] = bwlabel(BW_out)
    RGB(~cat(3,BW_out,BW_out,BW_out))=0;
end
댓글 수: 0
채택된 답변
  Etsuo Maeda
    
 2020년 1월 31일
        愚直にやるならこんなかんじですかね・・・
RGB = imread('peppers.png');
R = RGB(:, :, 1);
G = RGB(:, :, 2);
B = RGB(:, :, 3);
BW = rgb2gray(RGB);
map = jet(4) * 255;
for k = 1:4
    TF = BW >= 64*(k-1) & BW <= 64*k -1 ;
    R(TF) = map(k, 1);
    G(TF) = map(k, 2);
    B(TF) = map(k, 3);
end
sRGB(:, :, 1) = R;
sRGB(:, :, 2) = G;
sRGB(:, :, 3) = B;
imshow(sRGB)
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Marine and Underwater Vehicles에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
