caffe的matlab和python接口数据的处理
2017-05-13 15:47
369 查看
Python:
Matlab:
arr = np.load('ilsvrc_2012_mean.npy') print arr.shape # (3,256,256) channel * height * width ########## 数据的转置 ############### arr = np.transpose(arr,[1,2,0]) # height * width * channel print arr.shape ########## 通道的交换 ############### arr = arr[:,:,[2,1,0]] print arr.shape ################## test lena ########## img = imread('lena.jpg') img = img[:,:,(2,1,0)] # change from rgb to gbr img = img[:,:,(2,1,0)] # change back plt.imshow(arr) plt.show()
Matlab:
img = imread('lena.jpg'); % height * width * channel[rgb] %%%%%%%%%%%%%%%%% [h,w,c] to [w,h,c] %%%%%%%%%%%%% %%%%%%%%%%%% 因为matlab是按列存储的,caffe和python是按行存储的 imgforwd = permute(img,[2 1 3]); %%%%%%%%%%%%%%% rgb to bgr %%%%%%%%%%%%%% %%%%%%%%%%%因为caffe利用了opencv,opencv图像的存储就是bgr imgforwd = imgforwd(:,:,[3 2 1]); %%%%%%%%%%% 逆向回来 %%%%%%%%%%%% imgback = permute(imgforwd,[2,1,3]); imgback = imgback(:,:,[3,2,1]); figure; subplot(121),imshow(imgforwd); subplot(122),imshow(imgback);
相关文章推荐
- 在Windows下编译CAFFE并使用其matlab和python接口
- Caffe学习系列(13):数据可视化环境(python接口)配置
- windows配置caffe及matlab/python接口编译和调用(cpu/gpu)
- 【深度学习】笔记14 windows下caffe的python接口的配置(数据的可视化环境)
- Caffe——数据可视化环境(Python接口)配置
- 如何快糙好猛地在Windows下编译CAFFE并使用其matlab和python接口
- Caffe学习系列:数据可视化环境(python接口)配置
- 在ubuntu14.04下安装caffe并且做MATLAB和python的接口
- Caffe学习系列(11):数据可视化环境(python接口)配置
- 深度学习之Windows下安装caffe及配置Python和matlab接口
- Linux下配置Caffe及其Python接口全过程记录(Ubuntu15.10_amd64+CUDA7.5)及训练mnist数据集
- Caffe学习系列:数据可视化环境(python接口)配置
- 如何快糙好猛地在Windows下编译CAFFE并使用其matlab和python接口
- Caffe系列(11):数据可视化环境(python接口)配置
- 如何快糙好猛地在Windows下编译CAFFE并使用其matlab和python接口
- Caffe学习系列(13):数据可视化环境(python接口)配置
- 在ubuntu上配置cuda+cudnn+caffe(包括python和matlab接口)+digits
- 如何快糙好猛地在Windows下编译CAFFE并使用其matlab和python接口
- caffe-windows cpu下编译python接口/matlab接口
- python 和 matlab的caffe读数据细节