How to quantize histogram of gray scale image using LLoyd max algorithm upto 25 iterations
Show older comments
I have a gray scale images, i built histgram of it and find probability distribution function(Pdf) and corresponding greyscale values. i want to quantize it into non uniform bins( intervals) until i got MSE of all bins(intervals).
thank you in advance
Answers (1)
Image Analyst
on 23 Jan 2016
Edited: Image Analyst
on 23 Jan 2016
I'm not familiar with LLoyd, but if you define your bin edges, finding out what bin a gray level belongs in is trivial with the find() function. One of the ways
bin = find(grayLevel < edges, 1, 'first');
yourHist(bin) = yourHist(bin) + 1;
but that's so obvious you've probably tried it already, so at this point all I can say is to post your complete code so I can fix it.
Of course you can also have MATLAB do it with histcounts() where you can pass in the edges. Did you try that?
8 Comments
Naushad Varish
on 24 Jan 2016
Walter Roberson
on 24 Jan 2016
Image Analyst does not make his email address available. You can post a link to a description.
Walter Roberson
on 24 Jan 2016
With older MATLAB histc() is good for the calculations.
Image Analyst
on 24 Jan 2016
Edited: Image Analyst
on 24 Jan 2016
When you say "i built histogram of it" does that mean you have done it with equal width bins, or with the non-equal-width bins? If it's equal width bins, then of course that is useless as it's not something you'll need or can even use for non-equal-width bins.
I guess you don't know how to use the code I gave you in a for loop so I might do it for you if you make it super easy for me and give me the bin edges you want to use.
Usually I don't have the time to read, understand, and implement papers for people unless it's immediately relevant to my current job, or super interesting.
Naushad Varish
on 25 Jan 2016
Edited: Walter Roberson
on 25 Jan 2016
Image Analyst
on 25 Jan 2016
lloyds() is not "an inbuilt function" of base MATLAB, and is not in any of my toolboxes. What toolbox is it in, and can you add it to the Products List up at the top of the page?
Naushad Varish
on 27 Jan 2016
Image Analyst
on 27 Jan 2016
I'm using R2015b. Maybe they took it out then. If you type
which -all lloyds
it will tell you what toolbox it's in. If it's built-in you'll see something like this:
>> which -all plot
built-in (C:\Program Files\MATLAB\R2015b\toolbox\matlab\graph2d\plot)
plot is a built-in method
Otherwise you'll see some toolbox after the \toolbox\.
Also, the help for it also mentions which toolbox it's in.
Categories
Find more on Image Filtering and Enhancement in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!