How to translate ImageMagick commands into ImageMagick API calls? - imagemagick

I need to do some light image processing on large image, and I try to use ImageMagick for that. Unfortunately, the API documentation has a very low information content, with documentation similar to:
MagickDeleteImageArtifact
MagickDeleteImageArtifact() deletes a wand artifact.
The format of the MagickDeleteImageArtifact method is:
MagickBooleanType MagickDeleteImageArtifact(MagickWand *wand, const char *artifact)
A description of each parameter follows:
image
the image.
artifact
the image artifact.
Could anybody suggest a few information sources for ImageMagick that would have, you know, information?
(and yes, this piece of "documentation" is pasted from ImageMagick web site, with the incorrect parameter)
Edit: Here is the context: I develop an iOS application, so I want to call ImageMagick from the C language (or Objective-C or C++). The need is to split large images that would not fit in the limited amount of RAM of an iOS device into smaller "tiles" (and downsample for lower resolution versions too. But once I have the tiles, I can do that using only iOS facilities).
Edit 2: Using the command line, I can achieve this tiling with the "convert" command with corresponding parameters. So my immediate need would be to translate such a command line command into the relevant set of API calls.

Related

Difference between dcm2pnm, dcmj2pnm and dcml2pnm

The title says it all. What is the difference between dcm2pnm (http://support.dcmtk.org/docs/dcm2pnm.html), dcmj2pnm (http://support.dcmtk.org/docs/dcmj2pnm.html) and dcml2pnm (http://support.dcmtk.org/docs/dcml2pnm.html) commands of dcmtk toolkit (http://support.dcmtk.org/docs/pages.html)? They all seem to convert dicom images to other formats. Are there any special situations where one should be preferred over others?
Edit: It seems dcml2pnm supports more formats. Why not use that for all purposes? What are the advantages of other commands?
I am the DCMTK developer.
The difference between the three DCMTK command line tools is: support for compressed DICOM images and output formats.
dcm2pnm was the original tool that has been developed more than 20 years ago and which originally only supported the image format PNM/PGM for output (that's also why the tool is called "dcm2pnm" and not "dcm2img" or the like). And, because at that time the DCMTK did not support any encapsulated transfer syntaxes (i.e. compression), only uncompressed DICOM images can be read.
dcmj2pnm is located in DCMTK's submodule "dcmjpeg" and adds support for JPEG-compressed DICOM images (based on the IJG library) as well as the JPEG image format for output.
dcml2pnm is located in DCMTK's submodule "dcmjpls" and adds support for JPEG-LS-compressed DICOM images (based on the CharLS library). It does not support conventional JPEG.
All this is probably more obvious from the source code package than from the binary package but it is also mentioned in the above referenced documentation (see "Description" section).
If you'd ask why there are three different tools (in fact, there is also a fourth one for JPEG-2000 support but that not part of the public DCMTK), my answer would be: this is mainly for historical reasons but also for reason of keeping dependencies between the various DCMTK modules as simple as possible.
Furthermore, we consider the command line tools as a kind of sample applications of the underlying C++ class library. So, if you'd need a tool that supports all image compression schemes available in the DCMTK, it should be easy to write such a tool.
dcmj2pnm adds JPEG codecs to the dcm2pnm functionality. Thus, it is capable of handling JPEG compressed DICOM data and produce JPEG output images. So it is a superset of dcm2pnm's functionality.
I think this is, because dcmtk offers different compile options which allow to include / exclude libjpeg. Just reflects the toolkit's options to the accompanying command line tools. Confirmed by the list of file formats when you start with option -h
For dcml2pnm I am not sure, but this is a good guess: Same as for JPEG but includes the JPEG-LS encoder which is another optional 3rd party toolkit for dcmtk.

How to save images during debugging the code in opencv?

Im working on reducing noise from noisy image in OPENCV using different filters. i want to know that how i capture or save the result images during debugging code?
You can:
Save with imwrite all your debugging images, better in a specific folder.
Use Image Watch which will enable you to see all your Mat in a nice and powerful viewer during debugging. Just download and install it. You can access the Image Watch viewer in VS: View -> Other Windows -> Image Watch
I recommend the second approach, which personally I find very useful.
Have a look also at this answer.
If you can use CLion instead Visual Studio you can utilize the OpenCV Image Viewer plugin, which displays matrices while debugging with just one click. There is also an option to save the image on a disk.
https://plugins.jetbrains.com/plugin/14371-opencv-image-viewer
Disclaimer: I'm the author of this plugin

Creating DDS(DXT5) from two files (RGB+Alpha). Command line tool need

I need some command-line tool to create dds (dxt5 format) from two .png files -- one with rgb channels and one with alpha. It's because I have a waste amount of images to process -- I can't do it manually. It's no problem for me to create script for generating batch file to process all images one by one, but I need tool to create dds from two png-s.
Anyone known such command-line tool ?
Thanks.
P.S. nvDXT.exe is very good but it can't combine rgb and alpha from different files.
If you have Photoshop, you could always use Batch Script (see Batch Scripting Tutorial for an example) to merge the channels (with NVidea plug in installed, you could probably even do the DDS conversion too). Just a thought.

Creating a bitmap object from tiff image

I have a page with a gallery where users upload images. I noticed that there is one particular user who uploaded 3 tiff images and that they cannot be accessed.
Exception type: System.ArgumentException
Exception message: Parameter is not valid.
It happens here:
using (Image photo = new Bitmap(new MemoryStream(photoData)))
Files seems to be ok, sice File.ReadAllBytes() works, I can download them using other method (the one not working is used for returning a resized image only), test locally and the exception is not thrown. Any ideas what could be the case? Unfortunatelly I dont know yet if this occurs for all tiff images uploaded by other users too.
Support for TIFF flavors (and there are many of them) depends on the version of Windows on your server. More precisely, it depends on GDI+ library's version.
Without seeing the TIFFs there is nothing more I can tell. But I can recommend you to try some 3rd party libraries just for TIFF files. There is de-facto standard libtiff library and I have ported it to C# some time ago. You might try the port.
There are some samples you might be interested in. I think Convert color TIFF to a 32-bit System.Drawing.Bitmap might be most eligible for your task.

Using ImageMagick from Command line in .Net?

I am using ImageMagick from Commandline in .Net? Although a .Net wrapper (ImageMagick.Net in codeplex) is available but it is still in alpha and does not have implementation for all the command line options e.g Distort, Montage. Therefore I am using System.Diagnostics.Process class to invoke the ImageMagick command line.
What are the Pros/Con of this approach? I can see a performance issue if I have to perform multiple transformation on the same image and if I invoke the command twice then the commandline will load the Image twice. Is there a way I can chain the commands so that output of the first transformation is feed into the second command?
It will definitely be slower, and when you chain commands, you are going to be encoding and decoding the image into a format unnecessarily -- if you do this, make sure you use a lossless format like PNG for intermediate formats. To speed it up, use one without compression.
Two other choices
Use ImageMagick.NET and then wrap anything else you need from imagemagick yourself, probably by contributing to the project
My company, Atalasoft, has a free .NET imaging SDK with a lot of overlap with ImageMagick. You can download here: http://atalasoft.com/photofree -- Montage is basically the same as our Overlay commands and Distort is a 2D transformation, which are all included. If ImageMagick.NET can accept and produce .NET Bitmap objects, then you can use both together fairly easily.

Resources