How to extract colour descriptor (set of features) from the image?

조회 수: 7 (최근 30일)
Andrew Tim
Andrew Tim 2015년 7월 3일
댓글: nissrine Neyy 2021년 1월 23일
Hello, I have the following task. I want to compute the color histogram of an Image in HSV color space. For that I want to uniformly quantize the HSV color space into 240 cubes in which the quantization of each channel is 15 hues (H), 4 saturations (S) and 4 intensities (V ) respectively. And after making this color histogram the values of each bin is my 240 dim vector of color features which I want to get finally. Could someone please help me with the m-code for this task or with the high level plan how to create it? I will really appreciate it. Thank you.

채택된 답변

Image Analyst
Image Analyst 2015년 7월 3일
Loop over every pixel in the image and determine the bin, then increment the count. Here's a start
[rows, columns, numberOfColorChannels] = size(rgbImage);
hsvImage = rgb2hsv(rgbImage); % Ranges from 0 to 1.
hsvHist = zeros(15,4,4);
for col = 1 : columns
for row = 1 : rows
hBin = floor(hsvImage(row, column, 1) * 15);
sBin = floor(hsvImage(row, column, 2) * 4);
vBin = floor(hsvImage(row, column, 3) * 4);
hsvHist(hBin, sBin, vBin) = hsvHist(hBin, sBin, vBin) + 1;
end
end
  댓글 수: 17
Image Analyst
Image Analyst 2021년 1월 23일
nissrine, note that an array defined as zeros(n1, n2, n3) is always a 3-D array regardless of what the values of n1, n2, and n3 are.
Now h, s, and v are basically continuous variables in the range of 0-1 and the poster wanted to divide the range of h into 16 bins and s and v into 4 bins.
nissrine Neyy
nissrine Neyy 2021년 1월 23일
Okey, got it now .. thank you so much :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by