rgb2ind equivalent for grayscale images - NOT gray2ind because its not the same, at all.

조회 수: 4 (최근 30일)
So I love that rgb2ind finds the best matching colors for the number of colors that you want and that you have the option of no dithering, but I realized that finding the best colors in a NxMx3 matrix is probably a lot more computationally expensive than just doing a grayscale image.
The gray2ind just does an even colormap split based on the number of colors you want, not the image itself, for instance, if I want 3 colors, it just bins it like [0 .5 1] which I find not useful at all in this case.
Having both the no dithering option and the color approximation based on image values are important to me, does anyone have a suggestion?

채택된 답변

Image Analyst
Image Analyst 2013년 3월 13일
There is a new imquantize() function. You should probably be using imquantize() for grayscale quantization rather than gray2ind(). I don't see any need for gray2ind().

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 3월 13일
Work around:
rgb2ind( YourGrayImage(:,:,[1 1 1]), N )
  댓글 수: 3
Walter Roberson
Walter Roberson 2013년 3월 13일
I didn't say it would be efficient performance: it is a work-around, to provide the functionality of finding the "best" colors.
Shaun VanWeelden
Shaun VanWeelden 2013년 3월 13일
haha well thank you anyway, I do appreciate it and I hadn't thought of doing grayImg(:,:,[1 1 1]) before, I usually use repmat, that is a nice trick!

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by