Using CV2 to read the image and use Matlab to read the image in each channel value is different, cv2 read into the form of Bgr,matlab read in the form of RGB.
Original Image:
Python uses Cv2.imread () to read pictures and display
Read the image after it needs to be processed before it can be used by the network, specific methods see my previous article:
http://blog.csdn.net/qq_30401249/article/details/71429895
Import OS
import cv2
import matplotlib.pyplot as plt
im_name = ' 000456.jpg '
print ' Demo for data/demo/{} '. Format (im_name)
# go into def demo (NET, image_name):
im_file = Os.path.join (' Data/demo ', im_name)
im_o = Cv2.imread (im_file)
print im_o
im = im_o[:,:, (2, 1, 0)] # change channel
fig, ax = plt.subplots (figsize= (12 )
ax.imshow (IM, aspect= ' equal ')
plt.axis (' off ')
plt.tight_layout ()
Plt.draw () Plt.show ()
matlab reading image
>> b=imread (' 000456.jpg ');
>> x = B (:,:, 1); # channel R
>> y = B (:,:, 2); # channel G
>> z = B (:,:, 3); # Channel B