I have applied histogram on the v-component of hsv image how can i now convert it back to colour image
조회 수: 1 (최근 30일)
이전 댓글 표시
i have selected a color image, after reading it i have converted it to hsv image, then i have extracted its v-component, then applied histogram to the v-component, after this the image is of 256*1 matrix. how i now obtain the color image using the enhanced value of v after combining h s & v components
X = imread('4.1.05.tiff'); % read the image [o k]=size(X); S=rgb2hsv(X); [m n]=size(S); subplot(2,2,1) imshow(S) %convert the colour image to HSV V=S(:,:,3); subplot(2,2,2) imshow(V) subplot(2,2,3) [COUNTS,f] = imhist(V) stem(f,COUNTS); figure() imshow([COUNTS,f])
답변 (1개)
Image Analyst
2014년 12월 20일
Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
rgbImage = imread('peppers.png'); % read the image
[rows1, columns1, numberOfChannels1] = size(rgbImage);
subplot(2, 2, 1);
imshow(rgbImage);
title('RGB Image', 'FontSize', fontSize);
hsvImage=rgb2hsv(rgbImage);
[rows2, columns2, numberOfChannels2]=size(hsvImage)
subplot(2, 2, 2);
imshow(hsvImage) % Convert the colour image to HSV
title('HSV image, coded as RGB (meaningless)', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
H = hsvImage(:,:,1);
S =hsvImage(:,:,2);
V = hsvImage(:,:,3);
subplot(2, 2, 3);
imshow(V)
title('V Channel', 'FontSize', fontSize);
subplot(2, 2, 4);
[COUNTS,f] = imhist(V)
bar(f,COUNTS);
grid on;
title('V Channel Histogram', 'FontSize', fontSize);
figure()
improvedHSVImage = cat(3, H, S, mat2gray(V));
improvedRGBImage = hsv2rgb(improvedHSVImage);
imshow(improvedRGBImage)
title('Improved RGB Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!