How to overlay original image with created filled circle?

1 回表示 (過去 30 日間)
Ivan Shorokhov
Ivan Shorokhov 2015 年 2 月 17 日
コメント済み: Ivan Shorokhov 2015 年 2 月 18 日
Dear All,
I have following shape:
And I want to draw a filled circle above it (make a mask for this circle). I have tried following code, but it didn't work as I expected:
close all;clc; clear all;
original=imread('SA_r1.jpg'); % original=imread('u.jpg');
original=imresize(original,[500 500],'bicubic');% simple image interpolation.
bi= im2bw(original); % bi(binary image)
hbw = bwconvhull(bi);
[Clab, ~] = bwlabel(hbw);
st = regionprops(Clab,'Centroid','BoundingBox','Orientation','MajorAxisLength','MinorAxisLength');
figure; imshow(original); hold on;
xmin=floor(st.BoundingBox(1)); ymin=floor(st.BoundingBox(2));
xmax=floor(st.BoundingBox(1)+st.BoundingBox(3)); ymax=floor(st.BoundingBox(2)+st.BoundingBox(4));
figure; imshow(hbw,[]); hold on; sp_mean=15;
r1=floor(ymin-sp_mean); r2=floor(ymax+sp_mean);c1=floor(xmin-sp_mean);c2=floor(xmax+sp_mean);
rectangle('Position',[xmin-sp_mean, ymin-sp_mean, st.BoundingBox(3)+2*sp_mean, st.BoundingBox(4)+2*sp_mean], 'Curvature',[1,1],'FaceColor','w');
figure;
original(c1:c2,r1:r2)=rectangle('Position',[xmin-sp_mean, ymin-sp_mean, st.BoundingBox(3)+2*sp_mean, st.BoundingBox(4)+2*sp_mean], 'Curvature',[1,1],'FaceColor','w');
imshow(original); contour(original, [0,0], 'r');
Here is the results I have:
So I want to overlay original image with created filled circle and draw a contour of it.
Thanks for any help!

採用された回答

Image Analyst
Image Analyst 2015 年 2 月 17 日
I don't understand. What does "above it" mean to you: inteh overlay, or at a lower line number? And what does a contour mean when you're talking about a binary image? Do you want a transparent image in the overlay, like this: http://blogs.mathworks.com/steve/2009/02/18/image-overlay-using-transparency/ or this: http://www.mathworks.com/matlabcentral/answers/104889-how-to-overlay-a-foreground-image-over-a-background-image
  3 件のコメント
Ivan Shorokhov
Ivan Shorokhov 2015 年 2 月 18 日
@Image Analyst Thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Segmentation and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by