پاسخ : هیستوگرام افقی تصویر در مطلب
آفای هادی خیلی خیلی از شما ممنونم :applause:
آفای هادی خیلی خیلی از شما ممنونم :applause:
clear;clc;close all I = imread('C:\Users\reza\Desktop\2\HPIM0659.JPG'); p = rgb2gray(I); p1 = imfilter(p, [-1 0 1]); pf = im2bw(p1,graythresh(p1)); p22=im2double(pf); p2=edge(p22,'sobel','vertical'); p3= sum(p2,2); % miny = 1; maxy = length(p3); minx = 0; maxx = max(p3) + 10; subplot(2,2,1) colormap('default') imagesc([minx maxx],[miny maxy],I);title('Original') %freezeColors subplot(2,2,2) %colormap('Gray') imagesc([minx maxx],[miny maxy],p);title('Grayscale') %freezeColors subplot(2,2,3) colormap('Gray') imagesc([minx maxx],[miny maxy],p2);title('Binary') %freezeColors subplot(2,2,4) colormap('default') imagesc([minx maxx],[miny maxy],flipud(p2)); hold on;barh(flipud(p3));title('Horiz Projection') set(gca,'ydir','normal') % Hi = 0.55; [in,IX]= sort(p3,'descend'); Ind = IX(round((1-Hi)*length(IX)):end); % non-top 55% p3(Ind) = 0; % MinW = 15; MaxW = 35; regs = hist_reg(p3); remove = []; for i=1:size(regs,1) if regs(i,2)-regs(i,1)+1 < MinW || regs(i,2) - regs(i,1)+1 > MaxW remove = [remove, i]; end end regs(remove,:) = []; % x = [minx,maxx]; subplot(2,2,3);hold on for i = 1 : size(regs,1) y = [regs(i,1),regs(i,1)]; line(x,y,'color','y') y = [regs(i,2),regs(i,2)]; line(x,y,'color','r') end
دیدگاه