Info
此问题已关闭。 请重新打开它进行编辑或回答。
histograms of crossing count
3 次查看(过去 30 天)
显示 更早的评论
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
1 个评论
回答(2 个)
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
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
2013-1-14
It probably would, the larger the image the more you'd benefit. conv2 is highly optimized.
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!
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!