Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error while trying to read a grayscale image using load #475

Closed
josnar33 opened this issue Apr 21, 2016 · 12 comments
Closed

Getting error while trying to read a grayscale image using load #475

josnar33 opened this issue Apr 21, 2016 · 12 comments
Labels
enhancement Adds a new feature. help wanted

Comments

@josnar33
Copy link

I am new to Julia and trying to read few images using load. The function works fine for RBG4 images, however, fails with the following error for grayscale images -

WARNING: OSX reader: indexed color images not implemented

I would like to know if there is a way to read grayscale images in Julia. If not, is there some way to check for it using some other function. My ultimate goal is to have vectors created out of a collection of images, and some of them happen to be grayscale. Hence, I'm looking for a clean way to handle them (code below) -

img = imread(nameFile)
img_gsc = convert(Image{Gray}, img)
temp = float32(img_gsc)
x = vec(temp)
@rsrock
Copy link
Collaborator

rsrock commented Apr 21, 2016

That warning is telling you that your image is actually an indexed image, not a typical grayscale image. Or at least the Julia
IO code thinks you have an indexed image. However, the FileIO code should then try to load your image using ImageMagick.jl. Do you get an image in img? If so, you can safely ignore the warning. If not, you might need to do a Pkg.add("ImageMagick") once to get the ImageMagick code.

On Apr 20, 2016, at 9:25 PM, josnar33 <[email protected]mailto:[email protected]> wrote:

I am new to Julia and trying to read few images using load. The function works fine for RBG4 images, however, fails with the following error for grayscale images -

WARNING: OSX reader: indexed color images not implemented

I would like to know if there is a way to read grayscale images in Julia. If not, is there some way to check for it using some other function. My ultimate goal is to have vectors created out of a collection of images, and some of them happen to be grayscale. Hence, I'm looking for a clean way to handle them (code below) -

img = imread(nameFile)
img_gsc = convert(Image{Gray}, img)
temp = float32(img_gsc)
x = vec(temp)


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHubhttps://issues/475


Ronald S. Rock, Jr., Associate Professor
Dept. of Biochemistry and Molecular Biology, The University of Chicago
GCIS W240, 929 E. 57th St.
Chicago, IL 60637 USA
+1 773.702.0716 (w), +1 773.702.0439 (f)
[email protected]:[email protected]
http://gibraltar.uchicago.edu

@josnar33
Copy link
Author

Thanks @rsrock

Before ImageMagick, I was getting the following -

WARNING: OSX reader: indexed color images not implemented

julia> img

julia> show(img)
nothing

I tried adding ImageMagick and loading the file once again. However, even now, it shows 'nothing' -

julia> using ImageMagick
INFO: Precompiling module ImageMagick...

julia> img = load("284.bmp")
WARNING: OSX reader: indexed color images not implemented

julia> show(img)
nothing

@timholy
Copy link
Member

timholy commented Apr 21, 2016

Does img = ImageMagick.load("284.bmp") yield a better result?

@josnar33
Copy link
Author

Hi Tim,
ImageMagick load is giving me a new error -

julia> img = ImageMagick.load("284.bmp")
ERROR: no decode delegate for this image format `BMP' @ error/constitute.c/ReadImage/501
 in error at /Applications/Julia-0.4.5.app/Contents/Resources/julia/lib/julia/sys.dylib
 in error at /Users/josmol/.julia/v0.4/ImageMagick/src/libmagickwand.jl:153
 in readimage at /Users/josmol/.julia/v0.4/ImageMagick/src/libmagickwand.jl:232
 in load_ at /Users/josmol/.julia/v0.4/ImageMagick/src/ImageMagick.jl:78
 in load at /Users/josmol/.julia/v0.4/ImageMagick/src/ImageMagick.jl:64

@timholy
Copy link
Member

timholy commented Apr 21, 2016

What does Pkg.build("ImageMagick") say?

@josnar33
Copy link
Author

INFO: Building Homebrew
HEAD is now at 53c5089 CoreTap#install: fix clone target setting
HEAD is now at d45fe22 Merge pull request #91 from staticfloat/staging
INFO: Building ImageMagick

@timholy
Copy link
Member

timholy commented Apr 21, 2016

Hmm, seems OK but you're obviously still having trouble. See https:/JuliaIO/ImageMagick.jl#osx

@josnar33
Copy link
Author

Thanks @timholy
I will try both the options and update. For now, I have removed the indexed images (there were just a couple of them), and training using the remaining images.

@rjanjua
Copy link

rjanjua commented May 28, 2016

Getting the same issue, it seems like load is not falling back to ImageMagick for grayscale images. Using ImageMagick.load for the speciic grayscale images works for me, but as I understand it, I shouldn't have to do this explicitly.

@logankilpatrick
Copy link
Contributor

Any update on this @timholy ? I am getting an error when loading a greyscale image that says the following: ┌ Warning: QuartzImageIO: indexed color images not implemented └ @ QuartzImageIO ~/.julia/packages/QuartzImageIO/9DhKg/src/QuartzImageIO.jl:64 ERROR: LoadError: MethodError: no method matching getindex(::Nothing, ::StepRange{Int64,Int64}, ::StepRange{Int64,Int64}) Closest candidates are:

@logankilpatrick
Copy link
Contributor

doing ImageMagick.load worked!

@johnnychen94 johnnychen94 added help wanted enhancement Adds a new feature. labels Jan 1, 2020
@johnnychen94
Copy link
Member

Just housekeeping here. This seems to be an upstream QuartzImageIO issue to me, so if you still have this issue, open a new issue on https:/JuliaIO/QuartzImageIO.jl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adds a new feature. help wanted
Projects
None yet
Development

No branches or pull requests

6 participants