%Original Image %
sprintf('A: Original Image')
A = imread('test.jpg','jpg');
O = A;%Original Image
X = A;%result image will be modified by post procesings
A = rgb2gray(A);
A = im2double(A);
%preprocessings : splitmerge or something like that.
% Average = fspecial('average', 5);%just averaging
% A = imfilter(A, Average, 'conv');%just averaging
A=ordfilt2(A,5,ones(3,3));%median filter
subplot(2, 2, 1);imshow(A, [0 1]);title('A: Original Image');
subplot(2, 2, 2);plot(sum(A'))
subplot(2, 2, 3);plot(sum(A))
% Sobel vertical edge-emphasizing %
sprintf('B: Sobel vertical edge-emphasizing ')
Sobel = fspecial('sobel');
B = abs(imfilter(A, Sobel', 'conv'));
B = ordfilt2(B,36,ones(6,6));%6 by 6 maximum filter
subplot(2, 2, 1);imshow(B, [0 1]);title('B: Sobel vertical edge-emphasizing filter');
subplot(2, 2, 2);plot(sum(B')); v_histogram=sum(B');
subplot(2, 2, 3);plot(sum(B))
threshold = (sum(sum(B'))/prod(size(sum(B')))*70 + max(max(sum(B')))*30)/100;
for i = 1:prod(size(v_histogram))
if v_histogram(i)<threshold X(i, :, :) = 0;
end
end
subplot(2, 2, 4);imshow(X);
评论0