简体   繁体   English

读八度到读cv2

[英]imread octave to imread cv2

I have to translate a code from Octave to Python, among many things the program does something like this: 我必须将代码从Octave转换为Python,程序要做的许多事情如下:

load_image = imread('image.bmp') load_image = imread('image.bmp')

which as you can see its a bitmap, then if I do 正如您所看到的,它是位图,如果我这样做

size(load_image) that prints (1200,1600,3) which its ok, but, when I do: 可以打印(1200,1600,3)的size(load_image),但是,当我这样做时:

load_image load_image

it prints a one dimensional array, that does not make any sense to me, my question is how in Octave are these values interpreted because I have to load the same image in opencv and I couldn't find the way. 它打印一个一维数组,这对我来说没有任何意义,我的问题是如何在Octave中解释这些值,因为我必须在opencv中加载同一图像,而我找不到路。

thanks. 谢谢。

What you have is a 3D array in octave. 您拥有的是一个八度的3D阵列。 Here in the x-dimension you seem to have RGB values for each pixel and Y and Z dimension are the rows and columns respectively. 在x维度中,似乎每个像素都有RGB值,Y和Z维度分别是行和列。 However when you print it you will see all the values in the array and hence it looks like a 1D array. 但是,当您打印它时,您将看到数组中的所有值,因此它看起来像一维数组。

Try something like this and look at the output: 尝试这样的事情,然后看一下输出:

load_image(:,:,i)

The i stands for the dimensions of your image RGB. i代表图像RGB的尺寸。 If you want to 2D print your 3D image using matplotlib or similar, you need to do the same. 如果要使用matplotlib或类似工具2D打印3D图像,则需要执行相同操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM