Questions tagged [imread]

Use this tag for questions regarding reading images in OpenCV, Matlab or similar image processing languages.

cv::imread() and cv2.imread() are ways to read images using OpenCV in C++ and Python.

imread(filename) is how you would read the image in Matlab.

273 questions
5
votes
1 answer

Load images with OpenCV from assets folder in Android

I'm stuck trying to load an image placed in assets folder with OpenCV 3.0 in Android. I've read a lot of answers here, but I can't figure out what I'm doing wrong. "my image.jpg" is place directly in the assets folder created by Android Studio. This…
andraga91
  • 97
  • 2
  • 11
5
votes
3 answers

Load JPEG from URL to skimage without temporary file

Is it possible to load image in skimage (numpy matrix) format from URL without creating temporary file? skimage itself uses temporary files: https://github.com/scikit-image/scikit-image/blob/master/skimage/io/util.py#L23 Is there any way to pass…
user1263702
  • 123
  • 1
  • 10
5
votes
4 answers

C++ OpenCV imread not working in Android

I am trying to read an image in my C++ code LOGD("Loading image '%s' ...\n", (*inFile).c_str());; Mat img = imread(*inFile, CV_LOAD_IMAGE_GRAYSCALE); CV_Assert(img.data != 0); and get the following output: 09-25 17:08:24.798: D/IRISREC(12120):…
4ndro1d
  • 2,926
  • 7
  • 35
  • 65
4
votes
2 answers

OpenCV imread transparency gone

I have an image (a captcha) that I download from the web. When I loaded to opencv it seems to loose its properties or simply mixes the transparent background with the dark/black colors: Currently the code does nothing but loading a writing…
roccolocko
  • 562
  • 5
  • 17
4
votes
1 answer

MATLAB imread bmp image is not correct

I have a grayscale image. When I load it in MATLAB, I found that the gray levels don't match the original image. The read in image with MATLAB is more brighter than the original image. What am I doing wrong? How can I solve it? Left one is…
ShineZero
  • 89
  • 2
  • 7
4
votes
1 answer

How does imread scale 12bit images?

I have a 12-bit pgm-image, which I read with imread. The result is a 16-bit image having values in the full range 0 to 2^16 - 1. How does Matlab scale? Will X = imread('filename'); X = uint16(double(X)*((2^12-1)/(2^16-1))); recover the original…
jolo
  • 423
  • 3
  • 10
3
votes
0 answers

Insert PNG image in matplotlib figure with better quality

I am trying to insert PNG images in a matplotlib figure. Based on answers here and here, this is so far my code: import matplotlib import matplotlib.pyplot as plt import matplotlib.gridspec as gs from matplotlib.offsetbox import…
ma7642
  • 139
  • 2
  • 12
3
votes
2 answers

unable to load image with cv2.imread

I am trying to load an image using cv2.imread, but keep getting this error error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow' I googled the error and it seems that most of the time the problem is related to…
3
votes
1 answer

How to properly combine a log scale plot with a background image?

I produced data for a curve, stored in a list. Then I took 1000 random samples out of that data. The y-axis shows my data and the x-axis I the formula output. Up till here everything is fine. The problem starts when I want to plot my data onto an…
omerS
  • 817
  • 2
  • 9
  • 21
3
votes
2 answers

Unable to split opencv image to RGB

I'm trying to split an image into B,G,R but after splitting, each B G & R have grayscale images. import cv2 import numpy as np image = cv2.imread('/path/image.jpg') #I have tried using CV_LOAD_IMAGE_COLOR flag as well as 1 #however,image is read as…
Bamwani
  • 95
  • 1
  • 10
3
votes
1 answer

imwrite giving inconsistent error in Matlab

I wrote a code to clean and print multiple images, data_1=csvread(data) for h=1:30 im_old=imread(strcat('catches\image_generator (',int2str(h),').png')); im_bw=func_bw(im_old); im_2=func_clean_tr(im_bw); …
Pranav Totala
  • 148
  • 2
  • 14
3
votes
3 answers

Python + opencv with PyCharm- 'opencv' has no attribute 'imread'

A similar question to mine exists, however it does not answer my question. Here is what I am working with: Python v. 3.6.2 opencv 1.0.1 PyCharm Community Edition 2017 .2.2 macOS Sierra Version 10.12.6 I'm trying to use imread for image…
lane
  • 659
  • 8
  • 24
3
votes
2 answers

matplotlib changes jpg image color

I'm reading images from filesystem using matplotlib imread function. However, it changes jpg image color when it displays those images. [Python 3.5, Anaconda3 4.3, matplotlib2.0] # reading 5 color images of size 32x32 imgs_path =…
Shah-G
  • 652
  • 1
  • 8
  • 22
3
votes
0 answers

OpenCV: load image with alpha channel but 8bit depth

I am getting a bit confused with the flags that cv::imread takes. My goal is to load images that have an alpha channel with this alpha channel (i.e. as CV_8UC4). At the same time I want to load them always with a depth of 8bit. First of all I tried…
bweber
  • 3,772
  • 3
  • 32
  • 57
3
votes
1 answer

Inserting/adjusting png into plot [matplotlib]

I'm doing illustrations for my paper in python using matplotlib library. In this illustration I have a lot of lines, polygons, circles etc. But then I also want to insert a .png image from outside. Here's what I'm trying to do so far: import…
hayk
  • 388
  • 1
  • 5
  • 20
1
2
3
18 19