I have to compute an HSV histogram of a colored image. Is it same as an H-S histogram?
I have found H-S histogram computation code everywhere. What is the method to change an H-S histogram to an HSV?
Signal Processing Stack Exchange is a question and answer site for practitioners of the art and science of signal, image and video processing. It only takes a minute to sign up.Sign up to join this community
Since you want an histogram, I believe you want to plot it. In GNU Octave you may use hist3 and make three histograms (one for each pair: HxS, HxV and SxV). The code follows bellow:
pkg load statistics I = imread ('lena.png'); sI = size (I); Ihsv = rgb2hsv (I); figure ("position",get(0,"screensize")./[1 1 2 3]); subplot (1,3,1); hist3 ( reshape (permute (Ihsv(:,:,[1,2]), [3, 1, 2]), 2, prod(sI(1:2)))' ); title ('H vs S'); xlabel ('H'); ylabel ('S'); subplot (1,3,2); hist3 ( reshape (permute (Ihsv(:,:,[1,3]), [3, 1, 2]), 2, prod(sI(1:2)))' ); title ('H vs V'); xlabel ('H'); ylabel ('V'); subplot (1,3,3); hist3 ( reshape (permute (Ihsv(:,:,[2,3]), [3, 1, 2]), 2, prod(sI(1:2)))' ); title ('S vs V'); xlabel ('S'); ylabel ('V');
They are not the same. HSV histogram would involve computing the frequencies in a 3D cube where the volume is (depending on the implementation)
360x255x255. Due to the memory requirements, this is often not preferred (~90MB) (This might seem pretty small nowadays, but traversing this histogram is very inefficient because one cannot benefit from random accesses over CPU cache. In other words, accessing elements of the histogram - even to fill the entire volume causes tons of cache misses). In brief, I don't recommend computing this at all.
On the other hand, HS histogram is a simple 2D joint histogram with only
255x255 values. It can be cached and used even in real-time applications safely.