Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用ndimage.shift切换图像RGB通道_Python_Image Processing_Scipy_Python Imaging Library - Fatal编程技术网

Python 使用ndimage.shift切换图像RGB通道

Python 使用ndimage.shift切换图像RGB通道,python,image-processing,scipy,python-imaging-library,Python,Image Processing,Scipy,Python Imaging Library,我一直在尝试移动底部附加的一些测试图像中的RGB通道 如果图像为红色,则应显示绿色;如果图像为蓝色,则应显示红色;如果图像为绿色,则应显示蓝色 (RGB->GRB) 出于某种原因,ndimage.shift函数不会返回预期的结果,即使我确保它移动了正确的维度,使用“换行”模式确保通道循环移动。 看起来,在蓝色通道所在的位置,红色和蓝色通道是混合的,而在绿色通道所在的位置,我们有黑色像素 我知道如何使用拆分/合并,但我希望有人能澄清如何使用ndimage.shift。 谢谢 from PIL

我一直在尝试移动底部附加的一些测试图像中的RGB通道

如果图像为红色,则应显示绿色;如果图像为蓝色,则应显示红色;如果图像为绿色,则应显示蓝色

(RGB->GRB)

出于某种原因,ndimage.shift函数不会返回预期的结果,即使我确保它移动了正确的维度,使用“换行”模式确保通道循环移动。 看起来,在蓝色通道所在的位置,红色和蓝色通道是混合的,而在绿色通道所在的位置,我们有黑色像素

我知道如何使用拆分/合并,但我希望有人能澄清如何使用ndimage.shift。 谢谢

from PIL import Image
from scipy import ndimage as nd

test = Image.open('test.jpg')
img = nd.shift(test,(0,0,1) ,mode='wrap')
Image.fromarray(img).show()