I have applied histogram on the v-component of hsv image how can i now convert it back to colour image

1 visualización (últimos 30 días)
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])

Respuestas (1)

Image Analyst
Image Analyst el 20 de Dic. de 2014
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]);

Categorías

Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by