include include # IMVERIFY -- Bit by bit verification of two images # # B.Simon 14-Feb-89 Original procedure t_imverify () #-- pointer input1 # First input image template pointer input2 # Second input image template int maxdif # Maximum number of differences to print int nimage, ndif, idx, jdx, ndx, junk, size1, size2, idim pointer sp, errmsg, tplate1, tplate2, image1, image2, list1, list2, im1, im2 string imnumber "Number of images to verify are unequal" string gnumber "Number of groups in %s and %s are not the same" string badtype "Type of images %s and %s are not the same" string badsize "Size of images %s and %s are not the same" string enumber "%d bits different between %s and %s\n\n" int clgeti(), imtlen(), imtgetim(), tp_fetch() pointer immap(), imtopenp(), tp_open() begin # Allocate dynamic memory used to hold strings call smark (sp) call salloc (errmsg, SZ_LINE, TY_CHAR) call salloc (tplate1, SZ_FNAME, TY_CHAR) call salloc (tplate2, SZ_FNAME, TY_CHAR) call salloc (image1, SZ_FNAME, TY_CHAR) call salloc (image2, SZ_FNAME, TY_CHAR) # Read task parameters input1 = imtopenp ("input1") input2 = imtopenp ("input2") maxdif = clgeti ("maxdif") nimage = imtlen (input1) if (imtlen (input2) != nimage) call error (1, imnumber) # Loop over all images named in template do idx = 1, nimage { junk = imtgetim (input1, Memc[tplate1], SZ_FNAME) junk = imtgetim (input2, Memc[tplate2], SZ_FNAME) list1 = tp_open (Memc[tplate1], 0, size1) list2 = tp_open (Memc[tplate2], 0, size2) if (size1 == size2) ndx = max (1, size1) else { call tp_close (list1) call tp_close (list2) call sprintf (Memc[errmsg], SZ_LINE, gnumber) call pargstr (Memc[tplate1]) call pargstr (Memc[tplate2]) call error (1, Memc[errmsg]) } # Loop over all groups in the images ndif = 0 do jdx = 1, ndx { junk = tp_fetch (list1, Memc[image1]) junk = tp_fetch (list2, Memc[image2]) im1 = immap (Memc[image1], READ_ONLY, NULL) im2 = immap (Memc[image2], READ_ONLY, NULL) # Check for compatibility in size and type between images if (jdx == 1) { if (IM_PIXTYPE(im1) != IM_PIXTYPE(im2)) { call sprintf (Memc[errmsg], SZ_LINE, badtype) call pargstr (Memc[image1]) call pargstr (Memc[image2]) call error (1, Memc[errmsg]) } do idim = 1, IM_MAXDIM { if (IM_LEN(im1,idim) != IM_LEN(im2,idim)) { call sprintf (Memc[errmsg], SZ_LINE, badsize) call pargstr (Memc[image1]) call pargstr (Memc[image2]) call error (1, Memc[errmsg]) } } } # Bit verify the two groups call gverify (im1, im2, maxdif, ndif) call imunmap (im1) call imunmap (im2) } # Print total number of bits different between two images if (ndif > 0) { call printf (enumber) call pargi (ndif) call pargstr (Memc[tplate1]) call pargstr (Memc[tplate2]) call flush (STDOUT) } call tp_close (list1) call tp_close (list2) } # Task cleanup call imtclose (input1) call imtclose (input2) call sfree (sp) end