フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

histograms of crossing count

1 回表示 (過去 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