error: imread: invalid image file: Magick++ exception: Magick: - imagemagick

I have created the images using Gimp. The image is successfully loaded by octave's imread .But when I use convert command to resize the image and try to load in octave following errors occurs.
warning: your version of GraphicsMagick limits images to 16 bits per pixel
error: imread: invalid image file: Magick++ exception: Magick: Must specify image size (/home/tensor/Documents/Projects/ML/datasets/NepaliChar/KA/resize/makeMat.m) reported by coders/gray.c:128 (ReadGRAYImage)
I am using Arch Linux with Octave version 3.8.0 and ImageMagick 6.8.8-4

Reading a .GRAY image requires you to specify the dimensions of your image (e.g. 800x600). You have to do this because you are reading raw pixels.
According to the documentation you cannot specify the dimensions of your .GRAY image before reading it.

Related

Check in which Image in a dataset I get the warning libpng warning: iCCP: known incorrect sRGB profile while using OpenCV

I have a dataset, it has 2500 images. To access each of them and apply normalization, I loop over the images:
for path_to_image in dataset:
image = cv2.imread(path_to_image)
# rest of the code follows
While running the code I get this error/warning libpng warning: iCCP: known incorrect sRGB profile while using OpenCV
I tried to use some tricks to get the approximate value of iteration where the image is not being read properly but it did not work.
Is there any way I can obtain the variable path_to_image where I get this error?
What I was thinking is there must be a variable that stores some information about the warning.
Would be grateful for any help.

LibVIPS crashing when processing 3.9gb tiff image

I'm currently working on a project where I have an image of around 3.9gb. I want to create a google maps like view for this image (which is something LibVIPS can generate) by executing the following command:
vips-dev-8.1.1\bin\vips.exe dzsave testje-131072.tiff mydz
However when doing this some warnings are shown and after that the program crashes:
vips warning: tiff2vips: no resolution information for TIFF image "testje-131072.tiff" -- defaulting to 1 pixel per mm
vips warning: tiff2vips: no resolution information for TIFF image "testje-131072.tiff" -- defaulting to 1 pixel per mm
vips warning: vips_tracked: out of memory --- size == 48MB
Anyone got a clue what I could do to be able to process an image of this size using Vips? (Or any other library?).
I've done some investigation myself and it seems we need to have BigTiff, I've looked in the VIPS source code and saw the term BigTiff being used a number of times so I suppose it should be supported?
Some information about the image:
Width: 131072
Height: 131072
Chunks: 32x32 (4096x4096 each)
Compression: LZW
When opening the image in a tool like VLIV (Very Large Image Viewer) the image opens fine.
I'm the libvips maintainer. The vips.exe binary includes bigtiff support and should be easily able to process an image of this size. It's challenging to build yourself on Windows, perhaps a week's work, I wouldn't try to make your own unless you are very expert.
I think the problem is probably your input image. I think it is using very large tiles (4096 x 4096). libvips is having to keep two complete lines of tiles in memory, so 4096 x 131072 x 3 x 2 pixels, which is 3GB straight away.
I would remake your source image. Use smaller tiles, perhaps 512 x 512, and make sure you are writing a bigtiff image. Please open an issue on the libvips tracker if you still have problems, it's easier to debug stuff there.
https://github.com/jcupitt/libvips/issues
Edit: there's now an official 64-bit Windows build of libvips and vips.exe, it might help:
http://www.vips.ecs.soton.ac.uk/supported/current/win32/vips-dev-w64-8.1.1-2.zip

Read with 8 bits in Rmagick doesn't work correctly?

I have Rmagick using an ImageMagick compiled for 16bit.
However, I am able to read a file by doing this:
file = Magick::Image.read(my_file){self.depth = 8}.first
And when doing an inspect of that file, I see that it is
PNG 1400x768 1400x768+0+0 DirectClass 8-bit 333kb
However, when accessing any of the pixels, the values are bigger than 0-255.
Why is that? What am I missing?
I access it like this:
red = image.pixel_color(x,y).red
I don't understand why the value would be from 0 to 2^16, when I specifically have opened the image with 8 bits of depth.
The version of ImageMagick you are using is Q16 (16-bit). This means that ImageMagick will always use an unsigned short internally to store a channel of a pixel. You could switch to the Q8 version of ImageMagick if all your images are 8-bit. More info about the architecture of ImageMagick can be found here: http://www.imagemagick.org/script/architecture.php

Generating a 16-bits per channel PNG file procedurally

Is there any way to generate a 16-bits per channel(RGBA) PNG file using D3DX11SaveTextureToFile?
Or any version of DirectX, any image library(C++), any image format
I tried to use the sample code here:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb205131(v=vs.85).aspx
and modified the function names to D3D11 version.
The program works perfectly when I set the desc.Format to DXGI_FORMAT_R8G8B8A8_UNORM .
But the D3DX11SaveTextureToFile returns E_FAIL when I changed the desc.Format to DXGI_FORMAT_R16G16B16A16_UNORM .
I've tried to use DevIL (developer's image library) but it doesn't support 16-bits per channel png file.
The only format which can save all texture-formats is D3DX11_IFF_DDS. It seems that D3DX11SaveTextureToFile can't save 16Bit pngs. One possibility is to extract the imagedata of your texture and save it manually with one of the possibilities (e.g. OpenCV or libpng) discussed here: Writing 16 bit uncompressed image using OpenCV.

Paperclip::NotIdentifiedByImageMagickError in Spree::Admin::ImagesController#create

I am attempting to setup Spree for the first time. Everything was going well until I hit the image upload. I have installed Imageamgick using homebrew on Mac OSX Mountain Lion. Uploading any image gives me the following error.
Paperclip::NotIdentifiedByImageMagickError in Spree::Admin::ImagesController#create
Command :: identify -format %wx%h :file
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/fq/9g_6hmg513g6137rb6sbghw00000gn/T/stream20121005-26943-16883d4.png is not recognized by the 'identify' command.>
Paperclip::NotIdentifiedByImageMagickError (/var/folders/fq/9g_6hmg513g6137rb6sbghw00000gn/T/stream20121005-26943-16883d4.png is not recognized by the 'identify' command.):
paperclip (2.7.1) lib/paperclip/geometry.rb:29:in `from_file'
spree_core (1.2.0) app/models/spree/image.rb:35:in `find_dimensions'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__1794851703999987262__post_process__1580526166879208018__callbacks'
When I run identify from the command line I get the following output
Image Settings:
-alpha option on, activate, off, deactivate, set, opaque, copy
transparent, extract, background, or shape
-antialias remove pixel-aliasing
-authenticate password
decipher image with this password
-channel type apply option to select image channels
-colorspace type alternate image colorspace
-crop geometry cut out a rectangular region of the image
-define format:option
define one or more image format options
-density geometry horizontal and vertical density of the image
-depth value image depth
-extract geometry extract area from image
-features distance display image features (e.g. contrast, correlation)
-format "string" output formatted image characteristics
-fuzz distance colors within this distance are considered equal
-gamma value of gamma correction
-interlace type type of image interlacing scheme
-interpolate method pixel color interpolation method
-limit type value pixel cache resource limit
-monitor monitor progress
-ping efficiently determine image attributes
-quiet suppress all warning messages
-regard-warnings pay attention to warning messages
-respect-parentheses settings remain in effect until parenthesis boundary
-sampling-factor geometry
horizontal and vertical sampling factor
-seed value seed a new sequence of pseudo-random numbers
-set attribute value set an image attribute
-size geometry width and height of image
-strip strip image of all profiles and comments
-unique display the number of unique colors in the image
-units type the units of image resolution
-verbose print detailed information about the image
-virtual-pixel method
virtual pixel access method
Image Operators:
-negate replace every pixel with its complementary color
Miscellaneous Options:
-debug events display copious debugging information
-help print program options
-list type print a list of supported option arguments
-log format format of debugging information
-version print version information
By default, the image format of `file' is determined by its magic
number. To specify a particular image format, precede the filename
with an image format name and a colon (i.e. ps:image) or specify the
image type as the filename suffix (i.e. image.ps). Specify 'file' as
'-' for standard input or output.
Any help would be greatly appreciated.
Thanks,
Cory
My error was - “Paperclip::NotIdentifiedByImageMagickError in Spree::Admin::ImagesController”
I fixed this error some days ago.
Before that I tried:
Update XCode (with Command-Line Tools)
Update Imagemagick (i tried it from source and as binary module)
Update MacPort
Used Brew (refreshing with all dependencies for Imagemagic,
used “brew doctor”), not MacPort
Reinstall all gems that use Imagemagick
Bundle update
etc
And sure I had my “Paperclip::Attachment.default_options[:command_path]” option in production.rb file pointing to Imagemagick bin folder.
Several times i did it from a to z, again and again.
But nothing could help me.
By the way, in all cases i had worked fine “convert”, “identify” and “display” with test images of any kind, but not in my rails app (spree app).
I dived dipper and tried to do research inside rails console with
Paperclip.run("identify", "-format %m :file", :file => "/path/to/image”)
as paperclip do. And only new format (cocaine 0.4) of this command:
Paperclip.run("identify", "-format %m /path/to/image")
worked fine!!!
As a result, i found that cocaine 0.4 is the source of my problem. I tried downgrade to cocaine 0.3.2 in my Gemfile and my Spree app start working!!!
All i need to do is use cocaine 0.3.2 instead of 0.4!!!
Check if png format is in the list of compiled formats of identify:
identify -list format
If it's not, you might have to recompile it with these options:
./configure --prefix=/usr/local --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes
Also I met the problem when image file doesn't exists in public folder.
I've just copied a random file with the same name and everything started work.
parepclip 2.7.5 cocain 0.3.2

Resources