Caffe Learning notes: Python cv2.imread () read pictures and Matlab to read the difference between images __python

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.