% a pair of grayscale images
A = imread('cameraman.tif');
B = imrotate(A,5,'bicubic','crop'); % image "A" rotated a bit
% use IMFUSE
C = imfuse(A,B);
imshow(C)
% use our version where: Red=B, Green=A, Blue=B
C = cat(3, B, A, B);
imshow(C)
两者都应该给予你同样的东西:
编辑:
以下是Python/OpenCV版本:
import numpy as np
import cv2
A = cv2.imread(r"C:\path\to\a.png", 0)
B = cv2.imread(r"C:\path\to\b.png", 0)
#C = cv2.merge((B,A,B))
C = np.dstack((B,A,B))
cv2.imshow("imfuse",C)
cv2.waitKey(0)
import cv2
import numpy as np
# read the image
image = cv2.imread('image.png')
# read the edge image as grayscale
edges = cv2.imread('edges.png', cv2.IMREAD_GRAYSCALE)
# set the image to the red and blue channels and edges to the green channels
result = image.copy()
result[:,:,1] = edges
# save the results
cv2.imwrite('image_and_edges.png', result)
# show the results
cv2.imshow('result', result)
cv2.waitKey(0)
结果:
交替
使用
result = image.copy()
result[:,:,0] = edges
result[:,:,2] = edges
3条答案
按热度按时间osh3o9ms1#
默认情况下,
imfuse
只是以不同的色带覆盖这对图像(默认为Method=falsecolor
和ColorChannels=green-magenta
)。下面是MATLAB中的一个例子来说明(在Python/OpenCV中编写这个应该很容易):
两者都应该给予你同样的东西:
编辑:
以下是Python/OpenCV版本:
slsn1g292#
对于
SimpleITK
,给定以下MR输入图像:iklwldmw3#
下面是如何在Python/OpenCV/Numpy中做到这一点。
图片:
边缘:
结果:
交替
使用
结果: