How to draw histogram of hsv image?

조회 수: 20 (최근 30일)
kalyani bedekar
kalyani bedekar 2016년 3월 15일
댓글: sya zamani 2020년 4월 20일
Using imhist we canget histogram of grayscale image. How to draw histogram of hsv image?

답변 (3개)

Image Analyst
Image Analyst 2016년 3월 15일
Try this
hsvImage = rgb2hsv(rgbImage);
hImage = hsvImage(:, :, 1);
sImage = hsvImage(:, :, 2);
vImage = hsvImage(:, :, 3);
figure;
subplot(2,2,1);
hHist = histogram(hImage);
subplot(2,2,2);
sHist = histogram(sImage);
subplot(2,2,3);
vHist = histogram(vImage);
  댓글 수: 2
Mario Castro
Mario Castro 2018년 2월 7일
this code do not show any result at all. HSV values are represented in % and degrees.
Image Analyst
Image Analyst 2018년 2월 7일
Of course it does. Did you even run the code? You need to have rgbImage already read in. Here, here is a more complete demo:
rgbImage = imread('peppers.png');
hsvImage = rgb2hsv(rgbImage);
hImage = hsvImage(:, :, 1);
sImage = hsvImage(:, :, 2);
vImage = hsvImage(:, :, 3);
figure;
subplot(2,2,1);
hHist = histogram(hImage);
grid on;
title('Hue Histogram');
subplot(2,2,2);
sHist = histogram(sImage);
grid on;
title('Saturation Histogram');
subplot(2,2,3);
vHist = histogram(vImage);
grid on;
title('Value Histogram');
subplot(2,2,4);
imshow(rgbImage);

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


Anand
Anand 2016년 3월 15일
If you need the histogram only for visualization purposes, you can obtain it using the colorThresholder app.
Open the RGB image in the colorThresholder app and select the HSV color space. The right-hand pane will show histograms in H,S and V.
Open the image in the Color Thresholder:
>> colorThresholder(rgbImage)
Select HSV Color space.
  댓글 수: 1
sya zamani
sya zamani 2020년 4월 20일
Hi Anand, Sorry for the late question, do you know how to display the HSV histogram as shown in the colorThresholder app? Thanks in advance.

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


Yoon Thiri Zaw
Yoon Thiri Zaw 2019년 6월 18일
Can i find threshold values using Lab based color histogram? If having code, tell me please!
  댓글 수: 1
Image Analyst
Image Analyst 2019년 6월 18일
Depends on what threshold divides your color channel into foreground and background. No one can tell without seeing your image and an explanation of what you want (foreground) and what you don't want (background) to segment.

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

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by