Le mercredi 19 mars 2014 10:16:45 UTC+1, Jean-Patrick Pommier a écrit :
Hi,
I 'd like to modify continuously a pure red image to get an orange, yellow, green, light blue, blue, purple image.
The idea is to convert a rgb image, to convert it into hsv color space, to modify the hue value then to back convert into rgb color space.
The problem is that only green and blue can be obtained but no intermediate color:

According to adobe, adding a hue equal to 36 should yield a yellow image.

Here's the code:

from skimage import io
from skimage import color
from scipy import ndimage as nd
import numpy as np
from matplotlib import pyplot as plt
import os

cy55 = io.imread('/home/jeanpat/MFISH/PSI/P07/01/Cy5/P070109C.tif')

zero = np.zeros(cy55.shape,dtype=np.uint8)
rgb0 = np.dstack([cy55, zero,zero])

hue_rotations = [18, 36,72,90,108]
images = {}
images[0] = rgb0
hsv0 = color.rgb2hsv(rgb0)
for hue in hue_rotations:
    hsv = np.copy(hsv0)
    hsv[:,:,0] = hsv[:,:,0]+ hue
    rgb = color.hsv2rgb(hsv)
    images[hue] = rgb

The code to display the images is:

i = 1
plt.figure(num=None, figsize=(15, 5),  facecolor='w', edgecolor='k')
for hue in np.sort(images.keys()):
    plt.subplot(1,6,i,xticks=[],yticks=[])
    plt.title('hue='+str(hue))
    plt.imshow(images[hue])
    i = i +1
plt.show()


Any greyscaled image should be ok but the image used here is: