Thresholding based on energy
이전 댓글 표시
I have an image which is very sparse. I want to threshold the image by retaining a certain amount of energy. What is the most efficient way in matlab to perform thresholding based on energy.
답변 (1개)
Image Analyst
2019년 1월 7일
You need to compute the histogram, then the CDF:
numBins = 100; % whatever....
[counts, edges] = histcounts(energyImage, numBins);
cdf = cumsum(counts);
Now figure out what energy you want to remain. Let's say it should be in the darker gray levels rather than the brighter ones. Let's say it's 3.5e7 for example. Pick whatever number is right for your situation. Then find the energy level of the CDF that has that energy
remainingEnergy = 3.5e7; % Whatever....
index = find(cdf > remainingEnergy, 1, 'first')
% Now find edge where this occurs
thresholdLevel = edges(index);
% Now threshold the image at that level:
binaryImage = energyImage < thresholdLevel;
It's probably the most efficient way.
댓글 수: 4
D_coder
2019년 1월 7일
Image Analyst
2019년 1월 7일
편집: Image Analyst
2019년 1월 7일
Not efficiently. You could basically just start thresholding at a low value (0), then sum up the energy equal to or less than the threshold, and if it's not high enough enregy, raise the threshold and try again. But why would you want to do this? It's not efficient.
Tell me what's wrong with you using the histogram???
Originally you said you wanted the "most efficient" way, and I gave you that. Why go to a less efficient way now? Why did you change your mind?
D_coder
2019년 1월 7일
Image Analyst
2019년 1월 7일
Anything and everything you do in MATLAB is data dependent. You use data, that's what you do. Another data dependent way is to call sort() and then cumsum() and then find(). This would be similar to the histogram method if you chose the histogram to have as many bins as pixels in the image.
카테고리
도움말 센터 및 File Exchange에서 Neighborhood and Block Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!