尋找矩形塊

clc;
close all;
clearvars;
img = imread('D:\Program Files (x86)\Tencent\QQ_data\491415198\FileRecv\sampleImage.bmp');
figure,imshow(img)
[count,bin] = imhist(img,256);
figure,stem(bin, count,'marker','none');
thresh = graythresh(img);
bw =im2bw(img, thresh);
figure,imshow(bw)

val1 = img(img>thresh*255);
thresh1 = otsu_thresh(val1);
bw1 = img>thresh1*255;
figure;imshow(bw1);

val2 = img(thresh*255<img & img<thresh1*255);
thresh2 = otsu_thresh(val2);
bw2 = thresh<img&img<thresh2*255;
figure, imshow(bw2);

se = ones(5);
bw3 = imopen(bw2,se);
figure,imshow(bw3);
bw4 = imerode(bw3,se);
figure,imshow(bw4);
imgy = sum(bw3,2);figure,plot(imgy);
imgx = sum(bw3,1);figure,plot(imgx);


left = img(1:end,100:320);
histeq(left,256)
[left1] = histeq(left,256);
left2 =im2bw(left1,graythresh(left1));
figure,imshow(left2);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章