Skip to content

Instantly share code, notes, and snippets.

@thmosqueiro
Last active August 1, 2017 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmosqueiro/c33d7ca4da8d255361e1c2e032ed3607 to your computer and use it in GitHub Desktop.
Save thmosqueiro/c33d7ca4da8d255361e1c2e032ed3607 to your computer and use it in GitHub Desktop.
def convert( image, theta0 = 0. ):
numChannels = image.shape[2]
numPixelX = image.shape[0]
numPixelY = image.shape[1]
newImage = np.zeros( (numPixelX, numPixelY, 3) )
normSum = np.zeros( (3) )
for n in range(numChannels):
rgbLevels = colorsys.hsv_to_rgb(float(n)/numChannels + theta0, 1.0, 1.0)
normSum += rgbLevels
Rj = np.zeros( (numPixelX,numPixelY,3) )
for j in range(3):
Rj[:,:,j] = image[:,:,n]*rgbLevels[j]
newImage += Rj/Rj.max()*image[:,:,n].max()
newImage = newImage / normSum
return newImage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment