I'm trying to port a ver cool set of tools/script by Cedric Bompart to Windows, you can find them here:
http://cbompart.wordpress.com/
What I need is a tool that calculates the exposure difference between two shots. Cedric used a "C" program but I have no C compiler for Windows, I wonder if I can use Identify in some way to compute the same?
In short words can I do what this "C" program does with identify or some commandline tool ?
Thanks!!
Here is the C program if you want to take a look:
Code: Select all
01 #include <stdio.h>
02 #include <stdlib.h>
03 #include <math.h>
04 #include <wand/MagickWand.h>
05
06 int main(int argc,char **argv) {
07 MagickBooleanType status;
08 MagickPixelPacket pixel1, pixel2;
09 MagickWand *image1, *image2;
10 PixelIterator *iterator1, *iterator2;
11 PixelWand **pixels1, **pixels2;
12
13 long y;
14 register long x;
15 unsigned long width;
16
17 double min = 65536 / pow(2, 6);
18 double max = 65536 * 0.9;
19 double sum1 = 0, sum2 = 0;
20
21 if (argc != 3) {
22 fprintf(stdout, "Usage: %s normal-image over-exposed-image\n", argv[0]);
23 exit(0);
24 }
25
26 MagickWandGenesis();
27 image1 = NewMagickWand();
28 status = MagickReadImage(image1, argv[1]);
29 if (status == MagickFalse) {
30 return -1;
31 }
32 image2 = NewMagickWand();
33 status = MagickReadImage(image2, argv[2]);
34 if (status == MagickFalse) {
35 return -1;
36 }
37
38 iterator1 = NewPixelIterator(image1);
39 iterator2 = NewPixelIterator(image2);
40 if ((iterator1 == (PixelIterator *) NULL) || (iterator2 == (PixelIterator *) NULL)) {
41 return -1;
42 }
43 for (y=0; y < (long) MagickGetImageHeight(image1); y++) {
44 pixels1 = PixelGetNextIteratorRow(iterator1, &width);
45 pixels2 = PixelGetNextIteratorRow(iterator2, &width);
46 if ((pixels1 == (PixelWand **) NULL) || (pixels2 == (PixelWand **) NULL)) {
47 break;
48 }
49 for (x=0; x < (long) width; x++) {
50 PixelGetMagickColor(pixels1[x], &pixel1);
51 PixelGetMagickColor(pixels2[x], &pixel2);
52 if ((pixel1.red >= min) && (pixel1.red <= max) && (pixel2.red >= min) && (pixel2.red <= max)) {
53 sum1 += pixel1.red;
54 sum2 += pixel2.red;
55 }
56 if ((pixel1.green >= min) && (pixel1.green <= max) && (pixel2.green >= min) && (pixel2.green <= max)) {
57 sum1 += pixel1.green;
58 sum2 += pixel2.green;
59 }
60 if ((pixel1.blue >= min) && (pixel1.blue <= max) && (pixel2.blue >= min) && (pixel2.blue <= max)) {
61 sum1 += pixel1.blue;
62 sum2 += pixel2.blue;
63 }
64 }
65 }
66 if (y < (long) MagickGetImageHeight(image1)) {
67
68 return -1;
69 }
70 iterator1 = DestroyPixelIterator(iterator1);
71 image1 = DestroyMagickWand(image1);
72 iterator2 = DestroyPixelIterator(iterator2);
73 image2 = DestroyMagickWand(image2);
74 MagickWandTerminus();
75
76 printf("%.100g\n", sum1/sum2);
77 return(0);
78 }