Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

histograms of crossing count

2 Ansichten (letzte 30 Tage)
esser maalaoui
esser maalaoui am 14 Jan. 2013
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

Antworten (2)

Image Analyst
Image Analyst am 14 Jan. 2013
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 Kommentare
Amith Kamath
Amith Kamath am 14 Jan. 2013
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 am 14 Jan. 2013
It probably would, the larger the image the more you'd benefit. conv2 is highly optimized.

Amith Kamath
Amith Kamath am 14 Jan. 2013
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