New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation for color images in histogram matching #3865
base: main
Are you sure you want to change the base?
Conversation
Hello @Borda! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2019-04-27 14:59:53 UTC |
sigh, sphinx broke things for you..... |
@hmaarrfk I know, but it came from the actual master... :-/ |
Co-Authored-By: Borda <Borda@users.noreply.github.com>
Co-Authored-By: Borda <Borda@users.noreply.github.com>
Co-Authored-By: Borda <Borda@users.noreply.github.com>
I don't really understand what you are trying to say:
Can you explain in more words |
@hmaarrfk can you look at the updated version? |
@@ -49,11 +54,9 @@ def match_histograms(image, reference, multichannel=False): | |||
References | |||
---------- | |||
.. [1] http://paulbourke.net/miscellaneous/equalisation/ | |||
.. [2] https://www.researchgate.net/post/Histogram_matching_for_color_images |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to see a paper rather than a researchgate thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a similar topic here - mapbox/rio-hist#3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add the example, you can remove this link. The example will speak by itself.
@sciunto just to clarify, |
@Borda that is correct, you don't need to worry about Py2.7 support and can use syntax for Py3.5+, including the matmul symbol, |
the wording still isn't quite right:
ins't entirely grammatically correct. You should say something more like:
This is a fact.
General statement that encourages more thought. Finally, if you want to make this really awesome, I would encourage you to make an example with the images you used in the comment. |
@hmaarrfk example sounds reasonable, but would I include the image in this repo or download it online when needed? is there any guidence on how to create an example with new/own images? |
I think the first PR would be to add the image(s) to the dataset of images shipped with scikit-image. That PR would include:
It seems like you would include two images, the reference, and the source. Not sure how you got that data, but it seems that even lower res images might work to make your point, but high res images would be fine too. I'll push to include your full images. After you get the data in scikit-image, we can have a more focused discussion on how to improve the example and whatnot. |
I need to check the condition of sharing first and try to remember who is the source... |
def match_histograms(image, reference, multichannel=False): | ||
"""Adjust an image so that its cumulative histogram matches that of another. | ||
|
||
The adjustment is applied separately for each channel. | ||
|
||
For color image assume to use another colour space then RGB since the colour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @Borda, thank you for helping us clarify the documentation; that's always valuable.
I am struggling to understand the new text. Why do you say HSV is "continuous", and RGB is not? I can help wordsmith this a bit, but I don't have a good understanding of the issue at hand.
@@ -48,12 +53,10 @@ def match_histograms(image, reference, multichannel=False): | |||
|
|||
References | |||
---------- | |||
.. [1] http://paulbourke.net/miscellaneous/equalisation/ | |||
.. [1] http://paulbourke.net/miscellaneous/equalisation/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woops, I think all the futzing with this led to incorrect indentation.
it seems that with setting |
Can you add the full code? |
import os
import matplotlib.pyplot as plt
from skimage.io import imread
from skimage.transform import match_histograms
from skimage.color import rgb2hsv, hsv2rgb, rgb2lab, lab2rgb, lab2lch, lch2lab
rgb2lch = lambda im: rgb2lab(lab2lch(im))
lch2rgb = lambda im: lab2rgb(lch2lab(im))
path_imgs = 'https://raw.githubusercontent.com/Borda/BIRL/master/data_images/rat-kidney_/scale-5pc/'
path_img_ref = path_imgs + 'Rat-Kidney_HE.jpg'
path_img_move = path_imgs + 'Rat-Kidney_PanCytokeratin.jpg'
os.system('wget %s' % path_img_ref)
os.system('wget %s' % path_img_move)
img_ref = imread(os.path.basename(path_img_ref))
img_move = imread(os.path.basename(path_img_move))
use_multichannel = True
fig, axarr = plt.subplots(ncols=3, nrows=2, figsize=(12, 6))
axarr[0, 1].set_title('Reference')
axarr[0, 1].imshow(img_ref)
axarr[0, 0].set_title('Source')
axarr[0, 0].imshow(img_move)
axarr[0, 2].set_title('Hist. matching using RGB')
axarr[0, 2].imshow(match_histograms(img_move, img_ref, multichannel=use_multichannel))
axarr[1, 0].set_title('Hist. matching using HSV')
axarr[1, 0].imshow(hsv2rgb(match_histograms(rgb2hsv(img_move), rgb2hsv(img_ref), multichannel=use_multichannel)))
axarr[1, 1].set_title('Hist. matching using LAB')
axarr[1, 1].imshow(lab2rgb(match_histograms(rgb2lab(img_move), rgb2lab(img_ref), multichannel=use_multichannel)))
axarr[1, 2].set_title('Hist. matching using LCH')
axarr[1, 2].imshow(lch2rgb(match_histograms(rgb2lch(img_move), rgb2lch(img_ref), multichannel=use_multichannel))) |
@hmaarrfk do you think that it should/could be included or drop this PR? |
maybe you should rephrase your conclusion, and tell users to use multichannel=True for RGB images? |
@hmaarrfk Sure and in the doc of the function |
@hmaarrfk ^^ |
If you can add that to the docs, then just adding it there is fine. Otherwise, this should be a separate example. The documentation will find the example automatically I think |
I think showing it in an email example gallery will go a long way to helping others. Especially with syntax |
Description
cleaning unused variables and adding a note about using different colour space than RGB
Checklist
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.@meeseeksdev backport to v0.14.x