使用Otsu的方法进行图像处理,并获得白色/黑色图片的直方图和PDF。这是我编写的代码但我无法通过直方图获取PDF。
I = imread('sample.jpg');
level = graythresh(I);
X = rgb2gray(I);
A = im2bw(X,level);
A2 = im2bw(X,58/255);
B = medfilt2(A2);
figure, imshow(I)
figure, imhist(X)
figure, imshow(A)
figure, imshow(A2)
figure, imshow(B)
答案 0 :(得分:1)
imhist
仅显示直方图,而不显示PDF。如果您正在寻找X的PDF,您可以使用:
histogram( X(:), 'Normalization', 'probability' );
axis tight
编辑:完整代码
I = imread('sample.jpg');
level = graythresh(I);
X = rgb2gray(I);
A = im2bw(X,level);
A2 = im2bw(X,58/255);
B = medfilt2(A2);
figure, imshow(I)
figure; histogram( X(:), 'Normalization', 'probability' );
axis tight;
figure, imshow(A)
figure, imshow(A2)
figure, imshow(B)