Image Processing Toolbox入门
1.图像的导入导出
I=imread(path)
imshow(I)
whos I
imwrite(I,path)
imfinfo(path)
2.图像对比度调整
figure
imhist(I)
I2 = histeq(I)
I2 = imadjust(I)
3.找圆
[centers,radius] = imfindcircles(I,[20 25],"ObjectPolarity","dark")
[centers,radius] = imfindcircles(I,[20 25],"ObjectPolarity","dark",“Sensitivity”,0.9)
h = viscircles(centers,radius)
hBright = viscircles(centers,radius,"Color","b")
4.图像的预处理
level = graythresh(I)
L=watershed(I)
se = strel('disk',15)
background = imopen(I,se)
I2 = I - background
I2 = imtophat(I,strel('disk',15))
I3 = imadjust(I2)
bw = imbinarize(I3)
bw = bwareaopen(bw,50)
cc=bwconncomp(bw,4)
cc.NumObjects
labeled = labelmatrix(cc)
RGB_label = label2rgb(labeled,'spring','c','shuffle')
graindata = regionprops(cc,'basic')
grain_areas = [graindata.Area];
[min_area, idx] = min(grain_areas)
histogram(grain_areas)