필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

histograms of crossing count

조회 수: 2 (최근 30일)
esser maalaoui
esser maalaoui 2013년 1월 14일
i have 2 histograms of crossing count of image (horizontal and vertical), crossing count is the number of times the pixel value changes from 0 to 1 allong vertical or horizontal scan line. the task here is to devide this histogram into five bins with equal width and use five gaussian-chaped weight windows to get the final values please help me it is urgent

답변 (2개)

Image Analyst
Image Analyst 2013년 1월 14일
You can do this without loops using conv2(), sum(), and histc():
binaryImage = randi(2, 5, 10)-1 % Generate sample data.
% Get size so we can get edges for histograms.
[rows columns] = size(binaryImage);
% Find differences between element and prior one.
diffImageVertical = conv2(binaryImage, [1;-1], 'valid')> 0
diffImageHorizontal = conv2(binaryImage, [1,-1], 'valid') > 0
% Count number of rising edges.
edges = 0:1:(rows-1);
countsV = histc(sum(diffImageVertical, 1), edges)
edges = 0:1:(columns-1);
countsH = histc(sum(diffImageHorizontal, 2), edges)
  댓글 수: 2
Amith Kamath
Amith Kamath 2013년 1월 14일
Isn't this sort of a 1-D edge detection scheme with a filter [1 -1]? Interesting! Would this run faster?
Image Analyst
Image Analyst 2013년 1월 14일
It probably would, the larger the image the more you'd benefit. conv2 is highly optimized.

Amith Kamath
Amith Kamath 2013년 1월 14일
Thanks for the interesting question! I'm guessing you're trying something like this. The
I = (rand(500,500) >= 0.5);
%imshow(I)
hChanges = zeros(499,1);
vChanges = zeros(499,1);
for i = 1:499
for j = 1:499
if(I(i,j+1) ~= I(i,j))
vChanges(i) = vChanges(i) + 1;
end
if(I(i+1,j) ~= I(i,j))
hChanges(j) = hChanges(j) + 1;
end
end
end
hHist = hist(hChanges,5); % 5 bins.
vHist = hist(vChanges,5);
hHist and vHist should contain the 5 coefficients you're looking for. I'm not really sure what Gaussian shaped weight windows means, but I'm sure you can fit a gaussian on this data using normfit and the like!

이 질문은 마감되었습니다.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by