opencv与MATLAB打开同一图片,显示不一样,opencv右侧有空白区域

图片说明

这张图片是截图得到的,用matlab打开没有问题,用opencv打开就出现如图所示的问题,我是小白,求大神解答

1个回答

imread函数的参数没有传递正确,应该传大于零的参数,我记得:
Python: cv2.imread(filename[, flags]) → retvalC: IplImage* cvLoadImage(const char* filename, int flags=CV_LOAD_IMAGE_COLOR )C: CvMat* cvLoadImageM(const char* filename, int flags=CV_LOAD_IMAGE_COLOR )Python: cv.LoadImage(filename, flags=CV_LOAD_IMAGE_COLOR) → NonePython: cv.LoadImageM(filename, flags=CV_LOAD_IMAGE_COLOR) → None

Parameters:
filename – Name of file to be loaded.
flags –
Flags specifying the color type of a loaded image:
◦>0 Return a 3-channel color image
◦=0 Return a grayscale image
◦<0 Return the loaded image as is. Note that in the current implementation the alpha channel, if any, is stripped from the output image. For example, a 4-channel RGBA image is loaded as RGB if flags\ge0 .

The function imread loads an image from the specified file and returns it. If the image cannot be read (because of missing file, improper permissions, unsupported or invalid format), the function returns an empty matrix ( Mat::data==NULL ). Currently, the following file formats are supported:

Windows bitmaps - *.bmp, *.dib (always supported)
JPEG files - *.jpeg, *.jpg, *.jpe (see the Notes section)
JPEG 2000 files - *.jp2 (see the Notes section)
Portable Network Graphics - *.png (see the Notes section)
Portable image format - *.pbm, *.pgm, *.ppm (always supported)
Sun rasters - *.sr, *.ras (always supported)
TIFF files - *.tiff, *.tif (see the Notes section)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐