Image-Py / imagepy

Image process framework based on plugin like imagej, it is esay to glue with scipy.ndimage, scikit-image, opencv, simpleitk, mayavi...and any libraries based on numpy
http://imagepy.org
BSD 4-Clause "Original" or "Old" License
1.29k stars 330 forks source link

What causes Simple change the color of an image? #91

Closed CsatiZoltan closed 4 years ago

CsatiZoltan commented 4 years ago

I have an input RGB image: homogeneous_1_cropped If I apply Process -> Filter -> Median on it, I obtain the following filtered image: filtered_1 The median filter in ImagePy inherits from class Filter. However, if I want to replicate the same process using the Simple class, I get a different color: filtered_2 Why is it so? How can I keep the original color? My code is:

class FilterImage(Simple):
    """Median filtering of the current image."""
    title = 'Filter image'
    note = ['all', 'auto_msk', 'auto_snap', 'preview']
    para = {'size': 5}
    view = [(int, 'size', (1, 30), 0, 'window size', 'pixel')]

    def run(self, ips, imgs, para=None):
        out = median_filter(ips.img, para['size'])
        IPy.show_img([out], ips.title + '-filtered')

Additional information:

yxdragon commented 4 years ago

because median_filter treat the rgb image as a 3d image, So do filter in a cube.

you can loop the z channels yourself, or there is a skimage function can help you to go though the channels, (but I forgot the name).

you can see filter's base class, the 'not_channel' note. That's why the filter can fit multi-channels image.

yxdragon commented 4 years ago

by the way: how to upload image in issue?

CsatiZoltan commented 4 years ago

how to upload image in issue?

Simply drag&drop the image.

yxdragon commented 4 years ago

just have a try coins

CsatiZoltan commented 4 years ago

@yxdragon Just a tip: you can test whether uploading works without posting a message. After the drag&drop, click on the Preview tab.