SarthakJariwala / seaborn-image

High-level API for attractive and descriptive image visualization in Python
https://seaborn-image.readthedocs.io/
MIT License
66 stars 7 forks source link

Add a function like rgbplot for other color formats and generic data #580

Open eugenioLR opened 1 year ago

eugenioLR commented 1 year ago

I think it would be a good idea to make a function like rgbplot, showing the channels of each image separately, but not assuming it's an image in RGB, it could be an image in other color formats or even generic data (as could be the case in a deep learning problem) where there could be any number of channels to an image.

It could also be a good idea to make something like ImageGrid, but where each row is a different image and each column is a different channel of the image, but i'm not so sure about this because you can manually do it with existing functions.

I've made some code in this respect already, so if it this seems like a good idea i can make a pull request when we have discussed all the necesary details.

SarthakJariwala commented 1 year ago

Thanks for the suggestions, @eugenioLR!

Re your first suggestion: Please correct me if I'm misunderstanding your suggestion, but I thinkImageGrid already does this for generic data and all color formats, and rgbplot is just meant to be a specialized case of ImageGrid. Or are you suggesting a function like cmykplot?

Re second suggestion: I really like this idea and am open to having it as a feature. It could be a value add to make plotting these kinds of data easier. Can you propose the API you have in mind for this? And I agree; let's hash out the details about the API before the PR.

eugenioLR commented 1 year ago

For the first idea: Now that i think about it, you are right, you can already do this. However it could be nice to have the option to make the distinction between a sequence of images and a single image with multiple channels in terms of the names of the function, this could be implemented just as an alias, which is not that different from rgbplot.

This could be further distinguished from ImageGrid by having some default colormaps given by a parameter that could be called "img_format" or something like that, and could have as a value RGB, CMYK, HSV... that would assume the input image was in one of those formats and apply some colors by default. Maybe it could be interesting to also convert from RGB to HSV for example, but it is still true that i didn't realize you could do that already and it maybe is not as necessary as i thought.

For the second idea: The function to implement this could be called plot_channels or something similar and would receive a (N,X,Y,C) array or a list of N images of size (X, Y, C) as the input data. It would generate a NxC grid of images, where each row is a different image and each column is a different channel. The parameters that are passed as lists in ImageGrid like cmap would need to have a length of C, instead of the NxC size that was required with the other method and would be applied equally on each row. Esencially the API would be similar to ImageGrid but the parameters are given for each channel and replicated for each image.