Matlab中三点确定质心

clear all;close all;clc;
img=imread('E:\4.jpg');
subplot(121);imshow(img);
[x y]=size(img);%求像素大小!x=243,y=1026
img=double(img);%将img变成double类型的

%%sobel边缘检测
w=fspecial('sobel');%指定滤波器类型'sobel'
img_w=imfilter(img,w,'replicate');%求横边缘
w=w';
img_h=imfilter(img,w,'replicate');%求竖边缘
img=sqrt(img_w.^2+img_h.^2); %注意这里是平方和在开方
subplot(122);imshow(uint8(img))

impixelinfo;
A=ginput(3);
p= (A(1)+A(2)+A(3))/3;
q= (A(4)+A(5)+A(6))/3;
hold on;
plot(p,q,'*');
[p,q] %质点坐标

 

posted on 2014-09-10 20:32  图像处理工程师  阅读(869)  评论(0编辑  收藏  举报