简体   繁体   English

使用MATLAB /八度从RGB到HSV的图像转换回RGB

[英]Converting image using matlab / octave from rgb to hsv back to rgb

I'm trying to convert a color image from rgb to hsv (make changes) then back to rgb. 我正在尝试将彩色图像从rgb转换为hsv(进行更改),然后再转换回rgb。 As a test I made this code just to test how to go from rgb to hsv back to rgb but when I view the image it just shows up as black. 作为测试,我编写了这段代码,只是为了测试如何从rgb转到hsv回到rgb,但是当我查看图像时,它只是显示为黑色。 What am I missing? 我想念什么?

*PS I'm using octave 3.8.1 which works like matlab * PS我正在使用八度3.8.1,类似于matlab

Here are the octave 3.8.1 packages I have loaded:
>>> pkg list
Package Name  | Version | Installation directory
--------------+---------+-----------------------
     control *|   2.6.2 | /usr/share/octave/packages/control-2.6.2
     general *|   1.3.4 | /usr/share/octave/packages/general-1.3.4
    geometry *|   1.7.0 | /usr/share/octave/packages/geometry-1.7.0
    parallel *|   2.2.0 | /usr/share/octave/packages/parallel-2.2.0
      signal *|   1.2.2 | /usr/share/octave/packages/signal-1.2.2
     specfun *|   1.1.0 | /usr/share/octave/packages/specfun-1.1.0

test code below: 测试代码如下:

f=imread('/tmp/bump.jpg'); %color image

%Hue - Saturation - Value 
f_rgb2hsv=rgb2hsv(f); %convert image to HSV double
f_hsv2rgb=hsv2rgb(f_rgb2hsv);%convert to RGB double
f_to_image=uint8(f_hsv2rgb); %convert to uint8 to see image
imshow(f_to_image); 

凹凸图像

double images have values in range [0,1] (float), uint8 images in range [0,2^8-1] (only integers). double图像的值范围为[0,1](浮点数), uint8图像的值范围为[0,2^8-1] (仅整数)。 Using uint8 you simply convert your values between 0 and 1 to 0 and 1 which is black or nearly black. 使用uint8您只需将0到1之间的值转换为黑色或接近黑色的0到1。

Use im2uint8 or im2double to convert images, these functions automatically rescale your values to the appropriate range. 使用im2uint8im2double转换图像,这些功能会自动将值调整为适当的范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM