This is actually the correct link: https://drive.google.com/drive/folders/0B6BDW6BM-8ntTklnUW0xa0RaSWs?usp=sharing
How can I make a vector that counts pixels of a binary image??
1 次查看(过去 30 天)
显示 更早的评论
Hi everyone!
I have a matlab script that is used for motion detection. Basically you take a video and divide it into its frames, then the algorithm takes these frames, convert them in grayscale and creates a new video which is made of binary images that show if there's something moving in the pictures. Now I'd like to plot two histograms, one for each axis. Basically I would like to count for each row and column the number of white pixels (the ones that detect movement) and show this number at the sides of the binary video in a histogram that includes all the rows/columns at one time. This operation has to be performed for each frame of this video, so I can show how many pixels are involved in detecting motion.
I think that I should use a for statement loop, but I struggle to chose the correct data structure. The pixels I want to count are store in a variable called HOT_MAT
This is a link where you can find the code and the video I used: https://drive.google.com/open?id=0B6BDW6BM-8ntMmVmM3dCdzlESzg
Thanks you for any help you can provide
Could anyone show me how to do that, or give me some hints about this issue?
回答(1 个)
Image Analyst
2016-12-9
To sum the white/true/1 pixels in columns and rows do this:
columnCounts = sum(binaryImage, 1); % Counts along each column.
rowCounts = sum(binaryImage, 2); % Counts along each row.
2 个评论
Image Analyst
2016-12-9
What histogram? You have only two values in a binary image: 0 and 1. If you want you can make a bar chart out of the counts of the 0's and 1's:
bar([numColumns-columnCounts, columnCounts]);
bar([numRows-rowCounts, rowCounts]);
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!