Segmenting picture and placing into new picture using coordinates

2 ビュー (過去 30 日間)
Alexander Killam
Alexander Killam 2014 年 2 月 24 日
コメント済み: Image Analyst 2014 年 2 月 24 日
Hi I am having trouble uploading pictures or programs to this question. Basically this program I wrote segments the point of interest that i want and tells the coordinates of the center of that object. It also draws an outline of the segmented picture in the original program. now how would I take that outline and place it in a completely new picture. This program segments a heart from a blank background. Now I want to place that heart using the coordinates onto a background of a human. Im a basic beginner. Thank you for all your help!!
clc; close all; imtool close all; clear; workspace;
%Upload photo a=imread('C:\Users\a.c.killam\Pictures\a.jpg');
%Convert to Gray image I=rgb2gray(a);
%Find sobel Edge [~, threshold] = edge(I, 'sobel'); fudgeFactor = .99; E1 = edge(I,'sobel', threshold * fudgeFactor); figure, imshow(E1), title('sobel edge');
%Find roberts edge [~, threshold] = edge(I, 'roberts'); fudgeFactor = .99; E2 = edge(I,'roberts', threshold * fudgeFactor); figure, imshow(E2), title('roberts edge');
%Combine the two edged pictures Edge=E1+E2; figure, imshow(Edge), title('combined edge');
%Dilate edges se90 = strel('line', 9, 90); se0 = strel('line', 9, 0); Dilate= imdilate(Edge, [se90 se0]); figure, imshow(Dilate), title('dilated edge');
%Fill Interior Gaps Fill = imfill(Dilate, 'holes'); figure, imshow(Fill); title('Filled Gaps');
%Clear smaller pixels Clear=bwareaopen(Fill,100000); figure, imshow(Clear), title('cleared pixels');
%Clear Border ClearBorder = imclearborder(Clear); figure, imshow(ClearBorder), title('cleared border');
%Apply smoothing function seD = strel('diamond',9); AlmostFinal = imerode(ClearBorder,seD); Final = imerode(AlmostFinal,seD); figure, imshow(Final), title('final segmented image');
%Outline original image Outline = bwperim(Final,8); Segmentoutline = I; Segmentoutline(Outline) = 255;
%Dilate outlined original image se90 = strel('line', 9, 90); se0 = strel('line', 9, 0); Segmentoutlinedilate= imdilate(Segmentoutline, [se90 se0]); figure, imshow(Segmentoutlinedilate), title('outlined original image');
%Find Coordinates of Center s = regionprops(Final, 'centroid'); centroids = cat(1, s.Centroid); imshow(Segmentoutlinedilate) hold on plot(centroids(:,1), centroids(:,2), 'r*') hold off your_string = strcat('Center Coordinates','====', num2str(centroids(:,1)),'--', num2str(centroids(:,2))); text(-50,-50,your_string)

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by