1. 首页 > 热点 >

regionprops函数_regionprops函数使用

matlab函数文件中的错误

title('Original Image');%原始图像

照这个用

regionprops函数_regionprops函数使用regionprops函数_regionprops函数使用


function img = edu_imgpreprocess(for cnt = 1:50I) %图像预处理

Igray = rgb2gray(I); %转化成灰色图像

Ibw = im2bw(Igray,graythresh(Igray));%转化成二值 graythresh返回图像的阈值和阈值的有效性

Iedge = edge(uint8(Ibw));

se = strel('square',3);

Iedge2 = imdilate(Iedge, se);

Ifill= imfill(Iedge2,'holes');

[Ilabel num] = bwlabel(Ifill);

Iprops = regionprops(Ilabel);

Ibox = [Iprops.BoundingBox];

Ibox = reshape(Ibox,[4 50]);

Ic = [Iprops.Centroid];

Ic = reshape(Ic,[2 50]);

Ic = Ic';

Ic(:,3) = (mean(Ic.^2,2)).^(1/2);

Ic(:,4) = 1:50;

% Extra lines compare to example2 to extract all the components into an

% cell array

Ic2 = sortrows(Ic,2);

Ic2((cnt-1)10+1:cnt10,:) = sortrows(Ic2((cnt-1)10+1:cnt10,:),4);

end

Ic3 = Ic2(:,1:2);

ind = Ic2(:,4);

img{cnt} = imcrop(Ibw,Ibox(:,ind(cnt)));

end

怎么用matlab确定图像中矩形物体的位置及旋转角度

function W = Classify(ImageFile)

A=for i = 1 : length(STATS)imread('P5.jpg');

k=regionprops(A,'orientation');

a=k.orientation;

a;

看看regionprops函数,就会了。

如何用matlab图像处理函数将图像清晰化

centroid = STATS(i).Centroid;

% Step 1: Read image Read in

RGB = imread('C:\\test.bmp');%前提图像在该目录下

figure,

imshow(RGB),

% Step 2: Convert image from rgb to gray

GRAY = rgb2gray(RGB);

figure,

imshow(GRAY),

title('Gray Image');%灰度图像

% Step 3: Threshold the image Convert the image to black and white in order

% to prepare for boundary tracing using bwboundaries.

threshfor cnt = 1:5old = graythresh(GRAY);

BW = im2bw(GRAY, threshold);

figure,

imshow(BW),

title('Binary Image');%二值图像

% Step 4: Invert the Binary Image

BW = ~ BW;

figure,

imshow(BW),

title('Inverted Binary Image');%倒二值图像

% Step 5: Find the boundaries Concentrate only on the exterior boundaries.

% Option 'noholes' will accelerate the processing by prnting

% bwboundaries from searching for inner contours.

[B,L] = bwboundaries(BW, 'noholes');

% Step 6: Determine objects properties

STATS = regionprops(L, 'all'); % we need 'BoundingBox' and 'Extent'

% Step 7: Classify Shapes according to properties

% Square = 3 = (1 + 2) = (X=Y + Extent = 1)

% Rectangular = 2 = (0 + 2) = (only Extent = 1)

% Circle = 1 = (1 + 0) = (X=Y , Extent < 1)

% UNKNOWN = 0

figure,

imshow(RGB),

title('Results');

hold on

W(i) = uint8(abs(STATS(i).BoundingBox(3)-STATS(i).BoundingBox(4)) < 0.1);

W(i) = W(i) + 2 uint8((STATS(i).Extent - 1) == 0 );

switch W(i)

case 1

plot(centroid(1),centroid(2),'wO');

case 2

plot(centroid(1),centroid(2),'wX');

case 3

plot(centroid(1),centroid(2),'wS');

end

end

return

要看相关的文档才能知道Matlab中对应功能的函数名,如果知道函数名就好办多了,输入 函数名他就会告诉你怎么用。

Matlab中值滤波函数:medfilt2

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 12345678@qq.com 举报,一经查实,本站将立刻删除。

联系我们

工作日:9:30-18:30,节假日休息