这张图片是截图得到的,用matlab打开没有问题,用opencv打开就出现如图所示的问题,我是小白,求大神解答
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)