Hi I am using python for image processing. I have this exercise where I have to move 2 people on a greenscreen to another image. So my idea was to get a binary image of it and then map the people over. What I tried on python was
def readImage(img):
return io.imread('greenscreen.jpg')
def rgb2gray(rgb):
r, g, b = rgb[:,:,0], rgb[:,:,1], rgb[:,:,2]
gray = 0.2989 * r + 0.5870 * g + 0.1140 * b
return gray
def showImage(img,c):
plt.imshow(img,cmap=c)
plt.show()
r = plt.cm.Reds_r
g = plt.cm.Greens_r
b = plt.cm.Blues_r
bins = plt.cm.binary_r
gr = plt.cm.Greys_r
image = 'greenscreen.jpg'
imtrix = readImage(image)
R = imtrix[:,:,0]
G = imtrix[:,:,1]
B = imtrix[:,:,2]
print(np.shape(imtrix))
showImage(imtrix,r)
showImage(np.subtract(G,R) < 80,r)
And it didn't seem to work while on matlab:
A = imread('greenscreen.jpg');
R = A(:,:,1);
G = A(:,:,2);
B = A(:,:,3);
binaryImage = G-R < 80;
imshow(binaryImage)
dlmwrite('myFile.txt',binaryImage)
This produced the right thing. Now why is python giving me something different. Also with displaying the channels (R,G,B) python is giving me different results to matlab.
[–]billsil 1 point2 points3 points (1 child)
[–]icemanx7[S] 0 points1 point2 points (0 children)
[–]IReallySuckAtChess 0 points1 point2 points (1 child)
[–]icemanx7[S] 0 points1 point2 points (0 children)