GithubHelp home page GithubHelp logo

odegeasslbc / differentiable-rgb-to-hsv-convertion-pytorch Goto Github PK

View Code? Open in Web Editor NEW
46.0 1.0 6.0 7 KB

A pytorch implementation that converts image RGB color space into HSV allowing differentiable back-propagate

Python 100.00%

differentiable-rgb-to-hsv-convertion-pytorch's Introduction

Differentiable-RGB-to-HSV-convertion-pytorch

A pytorch implementation that converts image RGB color space into HSV allowing differentiable back-propagate

Value range

Each H,S,V are values in the range of [0, 1]

How to use

It comes within a Loss function

from pytorch_hsv import HSVLoss

target_h = 0 #red color
target_s = 0.5
target_v = 0.8
loss_hsv = HSVLoss(h=target_h, s=target_s, v=target_v, threshold_h=0.03, threshold_sv=0.1)

Convert rgb image into hsv space

img_rgb = torch.rand(1,3,256,256)
img_hue, img_saturation, img_value = loss_hsv.get_hsv(img_rgb)
# img_hue, ig_stauration and img_value each has the size of 1*256*256

Compute the loss given an image and target hsv

# you can compute the loss value between img_rgb and target h,s,v directly
loss = loss_hsv(img_rgb)

You can also convert back from hsv to rgb

r,g,b = loss_hsv.get_rgb_from_hsv()

differentiable-rgb-to-hsv-convertion-pytorch's People

Contributors

odegeasslbc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

differentiable-rgb-to-hsv-convertion-pytorch's Issues

HSV to RGB

Hi,

Thanks for the implementation. I am wondering why HSV to RGB conversion is not implemented as the same as RGB to HSV to recieve an image and converts rather than a pixel?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.