Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[56c6be]: tools / PTtiffdump.c Maximize Restore History

Download this file

PTtiffdump.c    178 lines (138 with data), 3.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
* PTtiffdump
*
* This program compares the contents of 2 different tiff files. If
* the byte is different it outputs it.
*
* May 2005
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* Author: Daniel M German dmgerman at uvic doooot ca
*
*/
#define PT_TIFF_DUMP_USAGE "PTtiffdump [options] <inputFile> <outputFile>\n\n"\
"Options:\n"\
"-o\t\tOverwrite output file if it exists\n"\
"\t-q\t\tQuiet run\n\t-h\t\tShow this message\n"\
"\n"
#define PT_TIFF_DUMP_VERSION "PTuncrop Version " VERSION ", by Daniel M German\n"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef _MSC_VER
#include <unistd.h>
#else
#include "compat_win32/getopt.h"
#endif
#include "tiffio.h"
#include "panorama.h"
#include "filter.h"
#include "PTcommon.h"
#include "pttiff.h"
int above = 0;
int below = 0;
int Compare(unsigned char *data1,
unsigned char *data2,
char channel, int x, int y)
{
char extra;
if (*data1 != *data2) {
if (*data1 > *data2) {
extra = 'A';
above++;
} else {
below++;
extra = 'B';
}
printf("%5d,%4d,%c,%3x %x, %c\n", x, y, channel, *data1, *data2, extra);
}
return 0;
}
int main(int argc,char *argv[])
{
char opt;
int overwrite = 0;
int filesCount;
char *inputFile, *otherFile;
Image im1;
Image im2;
unsigned char *data1, *data2;
int x, y;
int count;
//Need enough space for a message to be returned if something goes wrong
printf(PT_TIFF_DUMP_VERSION);
while ((opt = getopt(argc, argv, "ohq")) != -1) {
// o overwrite
// h -> help
// q -> quiet?
switch(opt) { // fhoqs f: 102 h:104 111 113 115 o:f:hsq
case 'o':
overwrite = 1;
break;
case 'q':
ptQuietFlag = 1;
break;
case 'h':
printf(PT_TIFF_DUMP_USAGE);
exit(0);
default:
break;
}
}
filesCount = argc - optind;
if (filesCount != 2) {
printf(PT_TIFF_DUMP_USAGE);
exit(0);
}
inputFile = argv[optind];
otherFile = argv[optind+1];
if (panoTiffRead(&im1, inputFile) == 0) {
PrintError("Unable to open input file");
goto error;
}
if (panoTiffRead(&im2, otherFile) == 0) {
PrintError("Unable to open input file");
goto error;
}
data1 = *(im1.data);
data2 = *(im2.data);
if (im1.width != im2.width ||
im1.height != im2.height) {
printf("The files have differente sizes %d,%d and %d,%d\n",
(int)im1.width, (int)im1.height, (int)im2.width, (int)im2.height);
}
printf("Comparing %d %d pixels\n", (int)im1.width, (int)im1.height);
count =0;
for (x=0;x<im1.width;x++) {
for (y=0;y<im2.height;y++) {
if (*data1 != 0) {
count++;
Compare(data1, data2, 'a', x, y);
Compare(data1+1, data2+1, 'r', x, y);
Compare(data1+2, data2+2, 'g', x, y);
Compare(data1+3, data2+3, 'b', x, y);
}
data1 +=4;
data2 +=4;
}
}
printf("Compared %d pixels %d above %d below \n", count, above, below);
printf("Percent of different values %5.3f\n", ((above + below) * 100.0) / (count * 3.0));
return 0;
error:
return 1;
}