I need a batch process for making mobile images and decided to use ImageMagick, but unfortunately one of my requirements is that the images produced are the same across OS's, since I'm sending them back and forth between my local system (Windows) and the server (Linux). It seems however whenever I call
convert test.jpg -resize 25% test-small.jpg
the process creates different images on both machines. I know this because when I use checksum the values aren't exactly the same.
Does anyone know of any reason why this would happen? And maybe some way around it, either via using a different executable or passing in a parameter that would produce the same images across OS's?
The files have more than the pixels in them -- If you are going to compare the images, write a checksum that works on just the decoded pixel data. That will at least tell you if the images would look the same. The internals of the file could be different because of a lot of factors.
Resizing is dependent on float arithmetic and you can't count on that to be the same across machines. So instead of using just a checksum, you might want to see if each pixel is within a tolerance from the associated one in the other file.
Take a look at these links:
http://pdiff.sourceforge.net/
http://www.phpied.com/image-diff/
JPEG algorithms are non-deterministic. There is no way to ensure that the same image will be generated across two systems, or even between two invocations on the same system.
Relying on 'checksum' or 'md5sum' or similar to compare two images isn't a wise choice. This can only verify if the files are indeed identical. However, if you have different results, this could be caused by just one byte in some random meta data value being different (like a simple timestamp), while there's no pixel difference at all.
To discover the pixel differences between two images, you can use ImageMagick's compare like this:
compare image1.jpg image2.jpg delta.jpg
For colored input images, the resulting delta.jpg willl use image1.jpb as a light-gray background and display the differences in red color. To get a red+white delta image without the light-gray background, use
compare image1.jpg image2.jpg -compose src delta.jpg
Examples images of this techniq can be found here:
ImageMagick: “Diff” an Image
Left: Image with text Center: Original image Right: Differences (=text) in red pixels.
Related
I am trying Tensorflow faster_rcnn_resnet101 model to detect multiple objects in a 642*481 image. I tried two ways but none got satisfactory results.
1) In this way, I cropped the objects (50*160 rectangle) from training images (training images might be at a different dim size than 642*481 test image). I use those cropped images to train the faster_rcnn_resnet101. Looks like it has good result if the test set is also a cropped image on the same size. But for the 642*481 test image, it could not detect multiple objects there with good results.
Then I think about maybe the model rescaled the test image to match the 50*160 so the details got lost. In this thought, I tried another way
2) I copied each cropped images into a 642*481 white background respectively (padding basically). So each training image has the same dim size as the test image. The location of the cropped images copied on the background is purposely set as random. However, it still does not have good detection on the test image.
To try its performance, I use GIMP to make windows that contain objects and replace other parts outside the windows with white pixels. The result is much better.
If we only keep one object window in the image and make other parts as white, the result is super.
So my question is what is happening behind those? How could I make it work to detect multiple objects in the test images successfully? Thanks.
The idea is that you should use training images containing multiple instances of objects during training. In other words, you don't have to crop ! Especially that your images are not very big.
However, you DO have to identify (label) the objects. This means to know the bounding box of each object in an image. Furthermore, this data should be assembled together with the original image in a tfrecord file. There is a good guide here with the whole process. In your case, you would label all objects in the source image (642x481), instead of just the "raccoon". If your objects have multiple classes, make sure you label them as so !
If you train with these images, which contain the objects in their contexts, then the network will learn to recognize similar images, which have objects in context.
I thought this was a little odd.
Open Paint on Windows (I'm using Windows 7) and draw something (anything).
Then save as a .png for example called 1.png. Then save 'n' number of other copies straight away without modifying the image (2.png, 3.png,..etc).
I notice that 1.png has a different checksum to 2/3/4/../n.png.
1.png also varies in such (sometimes smaller and other times bigger) compared to the other images.
What is going on?
The difference in filesize is due to the choice of scanline filters used by the compressor. I don't have any idea why your application would use a different set of filters when compressing the image multiple times, but it's harmless.
There's no time stamp in the two images that Mohammad posted. According to "pngcheck -v", the only difference is in the content of the IDAT chunk. The image signatures computed by ImageMagick are identical. Neither image contains a tIME chunk.
"pngcrush" produces two identical images with a smaller filesize (11493 bytes).
According to "pngtest -mv" (pngtest is included in the libpng distribution), one image uses only the PNG "none" filter while the other uses the "none", "sub", and "up" filters.
The Wikipedia article on the PNG format seems to suggest there's a timestamp in there. That alone would do it.
Doesn't explain why subsequent files have the same checksum.
I have two thousand large (20mb) image files. Each file has the same height, width, and resolution. The files are currently JPGs, though they are available in other formats.
For each image, I need to extract 6 cropped images from the larger file, each of which are in exactly the same location across the larger files.
I am looking to provide the coordinates of the regions I need extracted (or that I need each larger image cropped to) and then to loop through all 2,000 of the larger images and extract the size sub-images (specified by coordinates), from the larger images.
Is there a program, software package, or straight forward way to do this in python, Java, or some other language?
It seems that ImageMagick is exactly what you need.
ImageMagick has interfaces for Python, C and C++, Perl and Java. See full list of APIs on the page: http://www.imagemagick.org/script/api.php
Also uou can use mogrify utility (often comes with ImageMagick package), which can process images massively. Then your command line might look like this:
mogrify -crop 420x400+365+25 -path '/home/user/images' *.jpg
I have a series of images that change relatively little during the day, but suffer from severe over and underexposure sometimes. There's nothing I can do in the way of fixing the loss of details, however I want to make it so that one from to the next is not so jolting. In other words, I'd like to normalize brightness / color levels the sequence of images so that it feels more consistent from one from to the next. Ultimately this sequence is being encoded to a video and therefore why this is important to me.
How can I normalize these values for a series of a few hundred frames via ImageMagick or some other means?
Use ImageMagick command-line's -equalize option, that should do the trick. This will only adjust the current image to use its full color range properly.
If you want one image to match it's histogram and/or saturation to another, use this ImageMagick script.
I am working on a project in which I need to highlight the difference between pair of scanned images of text.
Example images are here and here.
I am building a webapp based on HTML,JS for this.
I found that openCV does support highlighting differences between 2 images.
Also I saw that imageMagick also has such support.
Does openCV has support for doing automatic registration of images?
And is there a JS module for openCV?
Which one is more suited for my purpose?
1. Simplistic way:
Suppose the images are perfectly aligned and similarly illuminated: subtract one image from another pixel by pixel, then threshold the result, filter out noisy blobs, and select the biggest ones. Good for a school project
2. A bit more complicated:
Align the images, then find a way to uniform the illumination, then apply the simplistic way.
How to align:
Find the text area in two images, as being a darker than the file color.
Find its corners
Use getPerspectiveTransform() to find the transform between images.
warpPerspective() one image to another.
Another way to register the two images is by feature matching. It has quite an extensive support in OpenCV. And findHomography() will estimate the pose between two images from a bigger set of matching points.
3. Canonical answer:
Align the image.
Convert it to text with an OCR engine.
Compare the text in the two images.
Well, besides the great help given by vasile, you also need the web app answer.
In order to make it work in a server, you will probably need a file upload form, as well as an answer from the server with the applied algorithm. There are several ways you can do it depending on the server restrictions you have. If you can run command line arguments, you would probably need to implement the highlight algorithm in opencv and pass the two input files a an output one for the program. A php script should be used for uploading the files, calling the command line program, and outputting the result to the user.
Another approach could be using java and JavaCV in a web container like Apache Tomcat, for instance.
Best regards,
Daniel