2017-11-20 25 views
0

私はcanny、sobel、logなどのエッジ検出方法に画像を取り込んで適用するスクリプトを用意しています。ファイルを実行すると、エッジが白い部分が描画されます。MATLABでエッジの色を変更する方法は?

エッジの色を好みの色に変更する方法はありますか?

function cw1 
    im0 = imread('lighthouse.png'); 
    im = rgb2gray(im0); 
    im3 = edge(im,'canny'); 
    im4 = edge(im, 'sobel'); 
    im5 = edge(im, 'log'); 
    im2 = my_edge1(im); 
    subplot(3,2,1), subimage(im); title ('Original'); axis off 
    subplot(3,2,2), subimage(im2); title ('My Edge'); axis off 
    subplot(3,2,3), subimage(im3); title ('Canny'); axis off 
    subplot(3,2,4), subimage(im4); title ('Sobel'); axis off 
    subplot(3,2,5), subimage(im5); title ('Log'); axis off 
end 
+0

密接に関連する/重複:[MATLABにおける輪郭検出(https://stackoverflow.com/q/5853116/52738) – gnovice

答えて

1

質問は正確には明確ではありませんが、とにかく助力していきます。ここで、緑のエッジを使用してデモの:

function q47394633 
    im = rgb2gray(imread('peppers.png')); 
    e = edge(im); % logical matrix, where "true" indicates an edge. 
    g = reshape(uint8([0 255 0]),[1,1,3]) .* uint8(e); % Turn the above to RGB while making 
    figure();           % only the green channel nonzero. 
    subplot(3,1,1); imshow(e); % Show white edges 
    subplot(3,1,2); imshow(g); % Show green edges 
    subplot(3,1,3); imshow(im+g); % Show green edges on the image 
end 

enter image description here

+0

はい、これが私は何を求めたかったのですか? – Rajan

+0

良いこの回答が役に立った場合は、この問題を解決するために[受諾](https://meta.stackexchange.com/q/5234)を検討してください。 –

+0

ここにコードはあります。https://drive.google.com/file/d/1i5te8--APn_yV-zzlbAriXJUf1gZl3si/view?usp=sharing – Rajan

関連する問題