How to avoid the pixels at 0 gray level , in the threhold -histogram template?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Dear Image Analyst
I am using your template of sliding threshold bars to threshold the histogram of the dicom image. By default , the histogram plots all the pixels including the pixels at 0 gray level.
What should I do , so that your template will plot the histogram of all gray levels , except the pixels at 0 gray level?
Thank you in advance
Accepted Answer
Image Analyst
on 19 Jan 2016
If you're talking about the interactive thresholding app in the File Exchange, http://www.mathworks.com/matlabcentral/fileexchange/29372-thresholding-an-image there is an input option to suppress certain bins of the histogram. For example you may have a masked image with a huge black surround that would show up a a very tall spike at zero that would make it hard to see all the other bars in the histogram. You can tell it to zero out that bin before displaying the bar chart so now all the other bars can be seen more easily.
binsToSuppress = 1; % Don't show huge spike at zero gray levels (due to mask)
[lowThreshold, highThreshold, lastThresholdedBand]=threshold(83, 255, monoImageArray, binsToSuppress);
7 Comments
Ruhul Amin
on 19 Jan 2016
Dear Image Analyst
Thanks for the reply. Yes, this is about your interactive thresholding application. But my problem is not in masked image. My problem is in the histogram of original monochrome image , that is displayed at the bottom of template. I need to suppress the black background pixels ( Huge number) of 0 gray level for the histogram of original monochrome image. I tried your codes but it does not work for this case. Is there any other codes to suppress the black background pixels of 0 gray level ( for the histogram of original monochrome image)? Thanks in advance
Image Analyst
on 19 Jan 2016
Explain why it does not work, or show me why. Post your image so I can threshold it myself. You should be able to suppress bins, based on the bin number (not the gray level). You need to give me something to illustrate why it doesn't work. If I can't see it or replicate it, I can't do anything, because it has worked for every image I've tried.
Ruhul Amin
on 20 Jan 2016
Dear Image Analyst
Thanks for the reply. I again tried and noticed that I have to write binsToSuppress = Y(1) ,where Y is my image . Then it is working properly. Actually, it was my mistake as I forgot to call the image .It is working perfectly now and I really thank you for your excellent interactive thresholding application m file and for all your help.
Image Analyst
on 20 Jan 2016
You must have a background taking up a lot of the image, and the upper left pixel value at Y(1) must be the same gray level as the background. The background may happen at some other gray level than 0, such as 89 or 126 or whatever. So that makes sense to suppress that one. The bins to suppress can also be an array, so if the background is from 80-90 then you can set binsToSuppress = 80:90.
Ruhul Amin
on 20 Jan 2016
Dear Image Analyst
Thanks. yes , that was the background and because of the huge no. of pixels in background , the histogram displayed out of the range in the screen. I am using dicom image in your template , so the gray level values are extended till 65535 , but the total no. of gray levels is 255 as your template is for 8 bit jpg or png, I guess. Still it can be used for dicom image I assume. Thanks again
Image Analyst
on 20 Jan 2016
Yes it can, though even though you have 65536 gray levels for a 16 bit image, I think I still bucket those into 256 bins for the histogram display. Right now the binsToSuppress refers to bins, not gray levels, so for example graylevel 65500 would be in bin 255. Perhaps I could have an option grayLevelsToSuppress where you could specify which bins to erase based on the gray level instead of the bin number - that might make it easier for people with images that are uint16 or double. What do you think?
Ruhul Amin
on 20 Jan 2016
Dear Image Analyst
Yes you are right. For example , it is easy to understand that bin 1 refers to gray level 0 , but for higher gray levels , it might not be possible to understand easily the bin no. that should be suppressed for a particular gray level. So if you can create an option referring bin no . for the corresponding gray levels , it will be helpful for sure. Thanks again.
More Answers (0)
Categories
Find more on Modify Image Colors in Help Center and File Exchange
Products
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)