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
Deprecating is_rgb() #532
Deprecating is_rgb() #532
Conversation
@@ -62,17 +62,6 @@ | |||
from ..util import dtype | |||
|
|||
|
|||
def is_rgb(image): |
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.
Deprecating means to preserve the current function, but raise a warning.
You can use the skimage.shared.deprecated decorator. There are a number of examples, how to use it.
@ahojnnes : Currently, there are six deprecated functions in skimage and all of them have a new function to manage the deprecated functionality. For this, how should I go on to write a function for checking whether an image is rgb or not? How would I differentiate between RGB and HSV images? |
Just do raise is_gray could simply look like this |
On Thu, Apr 25, 2013 at 11:27 PM, Johannes Schönberger <
Also, I think you mean np.squeeze(image).ndim == 2 =) |
I agree. @stefanv what do you think?
Yes… I changed that immediately after submitting the form, but emails won't update ;-) |
@stefanv : Waiting for your thought on this. |
It's a difficult problem. Simple dimensionality checks are always going to have counterexamples, particularly if we envision supporting 2d, 2d multichannel, 3d, and 3d multichannel data (to say nothing of n-D or n-D multichannel). The paths forward for this sort of functionality are really:
In my second case there is no real place for an |
@JDWarner : Another way would be to look how SimpleCV handles this, though I am not sure if it would properly fit in skimage: |
Hm, I am not sure if this is really necessary and I tend to think this complicates things. Every user of an image processing library should actually be aware of the underlying data he/she uses? Pure NumPy arrays are in my opinion the simplest and clearest way. (e.g. the novice module in another PR tries wrap arrays with Image/Pixel classes and I think it actually complicates rather simplifies things for new users... but that is my personal opinion). To sum it up: I'm in favor of deprecating both is_gray and is_rgb and remove it in the next version. Maybe keep is_gray for internal usage in functions in _shared... |
I tend to agree. @ahojnnes Do you have any suggestions for improving the |
Nobody asked me, but I strongly -1 the idea of a specific image class. I On Mon, Apr 29, 2013 at 3:16 AM, Stefan van der Walt <
|
Alright, I'm going to play devil's advocate here (I was actually against the idea until everyone else came out against it :). The Alternatively, we could add a standard flag to functions to indicate the image type, which would serve the same purpose as the meta-data. |
I should add: The benefit of suggesting that the user wrap the image in the We'd have to also make sure to propagate the class intelligently, but I think a lot of this could be handled by decorators (e.g. |
On Mon, Apr 29, 2013 at 11:59 AM, Tony S Yu notifications@github.comwrote:
This is exactly what I don't want. And in the case of raising, you can A library should get out of the way and let me work, not "helpfully" An easy alternative would be to warn only in cases when the last |
I like this idea. I guess for We would still want a convenience function that's similar to What about functions that work for multi-channel images, but not > 2D image data. We'd still want a convenience function to check the shape and last dimension, just like Thoughts? |
Here's another possibility that might help with readability:
|
For a function like |
Frankly, I don't think we want a replacement for this functionality right now. We seem to agree to deprecate the existing functions (not remove, but add If we go function-level multispectral using naked arrays, like |
@JDWarner : I was thinking to deprecate |
@ankit-maverick I understand, and in nearly all cases we aim to replace - not remove - functionality. However, I feel this is an exception to that rule. Once we reach consensus on the direction we want to go, we either don't need this at all or it will be available trivially from metadata. |
@@ -29,7 +29,7 @@ | |||
rgb2grey, gray2rgb, |
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.
We are missing a test case for is_gray_2d
or did I overlook it?
Sorry to keep kicking this to-and-fro, but do we really want to introduce |
@stefanv No, I agree, we should just get rid of those functions. But without reading the above answers in-depth, I thought the compromise was to keep is_gray_2d... shame on me ;-) |
:) Great, then let's take them out. |
@ankit-maverick We should deprecate both functions for a start and delete in the next release. |
As we have finally reached an end in this discussion, I'll merge! ;-) Thanks @ankit-maverick for going through this! |
I grepped for
is_rgb
and surprisingly didn't find it anywhere exceptcolorconv.py
andtest_colorconv.py
.Currently, the condition for testing for an rgb image in
is_gray()
in this commit is the same as one used inis_rgb()
which is a weak test in my opinion. Does anyone have better ideas for it?