📄 main.c
字号:
/*----------------------------------------------------------------------------
// StirMark Benchmark - main.c
//
// Contents: Program entry point for the self similarities attack
//
// Purpose: This can be used to compile the self similarities attack as
// a standalone progam
//
// Created: C. Rey, G. Do雛r, J.-L. Dugelay and G. Csurka, Eur閏om, January 2002
//
// Modified:
//
// History:
//
// Copyright (c) 2000-2002, Microsoft Research Ltd , Institut National
// de Recherche en Informatique et Automatique (INRIA), Institut Eur閏om
// and the Integrated Publication and Information Systems Institute at
// GMD - Forschungszentrum Informationstechnik GmbH (GMD-IPSI).
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted for non-commercial research and academic
// use only, provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer. Each
// individual file must retain its own copyright notice.
//
// - Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions, the following disclaimer and the
// list of contributors in the documentation and/or other materials
// provided with the distribution.
//
// - Modification of the program or portion of it is allowed provided
// that the modified files carry prominent notices stating where and
// when they have been changed. If you do modify this program you
// should send to the contributors a general description of the changes
// and send them a copy of your changes at their request. By sending
// any changes to this program to the contributors, you are granting a
// license on such changes under the same terms and conditions as
// provided in this license agreement. However, the contributors are
// under no obligation to accept your changes.
//
// - All non-commercial advertising materials mentioning features or use
// of this software must display the following acknowledgement:
//
// This product includes software developed by Microsoft Research
// Ltd, Institut National de Recherche en Informatique et Automatique
// (INRIA), Institut Eur閏om and the Integrated Publication and
// Information Systems Institute at GMD - Forschungszentrum
// Informationstechnik GmbH (GMD-IPSI).
//
// - Neither name of Microsoft Research Ltd, INRIA, Eur閏om and GMD-IPSI
// nor the names of their contributors may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// - If you use StirMark Benchmark for your research, please cite:
//
// Fabien A. P. Petitcolas, Martin Steinebach, Fr閐閞ic Raynal, Jana
// Dittmann, Caroline Fontaine, Nazim Fat鑣. A public automated
// web-based evaluation service for watermarking schemes: StirMark
// Benchmark. In Ping Wah Wong and Edward J. Delp, editors,
// proceedings of electronic imaging, security and watermarking of
// multimedia contents III, vol. 4314, San Jose, California, U.S.A.,
// 20-26 January 2001. The Society for imaging science and
// technology (I.S.&T.) and the international Society for optical
// engineering (SPIE). ISSN 0277-786X.
//
// and
//
// Fabien A. P. Petitcolas. Watermarking schemes
// evaluation. I.E.E.E. Signal Processing, vol. 17, no. 5,
// pp. 58-64, September 2000.
//
// THIS SOFTWARE IS NOT INTENDED FOR ANY COMMERCIAL APPLICATION AND IS
// PROVIDED BY MICROSOFT RESEARCH LTD, INRIA, EUR蒀OM, GMD-IPSI AND
// CONTRIBUTORS 'AS IS', WITH ALL FAULTS AND ANY EXPRESS OR IMPLIED
// REPRESENTATIONS OR WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE, TITLE OR NONINFRINGEMENT OF INTELLECTUAL
// PROPERTY ARE DISCLAIMED. IN NO EVENT SHALL MICROSOFT RESEARCH LTD,
// INRIA, EUR蒀OM, GMD-IPSI OR THEIR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// THE USE OF THIS SOFTWARE FOR CIRCUMVENTING WITHOUT AUTHORITY ANY
// EFFECTIVE TECHNOLOGICAL MEASURES DESIGNED TO PROTECT ANY COPYRIGHTS OR
// ANY RIGHTS RELATED TO COPYRIGHT AS PROVIDED BY LAW OR THE SUI GENERIS
// RIGHT PROVIDED BY SOME COUNTRIES IS STRICTLY PROHIBITED.
//
// $Header: /home/cvs/StirmarkBench/StirMark_Bench/SignalProcessing/SelfSimilarities/main.c,v 1.3 2002/04/19 10:23:59 petitcolas Exp $
//----------------------------------------------------------------------------
*/
#define SS_EXE
#ifdef WIN32
/* Memory leak detection
// Technical article: Edward Wright, "Detecting and Isolating Memory Leaks
// Using Microsoft Visual C++", MSDN, Microsoft Corporation, May 1999
*/
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif /* WIN32 */
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include "SelfSimilarities.h"
#include "compil.h"
#include "imgio.h"
/*--------------------------------------------------------------------------------*
| This function displays on the screen the version info of the attack. |
*--------------------------------------------------------------------------------*/
void printVersion(){
printf("*-----------------------------------------------------------------*\n");
printf("| Attack for watermarked images using self-similarities. |\n");
printf("| Version 0.1 (released March 2002) |\n");
printf("| Company: Eurecom Institute, France. |\n");
printf("| Authors: G. Doerr, G. Csurka, C. Rey, J.-L. Dugelay, |\n");
printf("| C. Mallauran, J.-P. Nguyen. |\n");
printf("| Companion paper: Internal Report RR-02-60. |\n");
printf("| Downloadable from http://www.eurecom.fr/~image |\n");
printf("*-----------------------------------------------------------------*\n\n");
}
/*--------------------------------------------------------------------------------*
| This function displays on the screen how to use the .exe |
*--------------------------------------------------------------------------------*/
void printUsage(){
printVersion();
printf("Usage: ");
printf("attack <origFilename> <waterFilename> <colorSpace>:<channels> <typeAttack> [<percent>]\n");
printf(" <origFilename>: image for IFS codebook in Portable Pixelmap \"*.ppm\"\n");
printf(" May be the same as <waterFilename> most of the time\n");
printf(" <waterFilename>: watermarked image to be attacked in Portable Pixelmap \"*.ppm\"\n");
printf(" <colorSpace>: rgb, yuv, hsv or lab in lower case\n");
printf(" <channels>: channels of the color space to be attacked in lower case\n");
printf(" <typeAttack>: x for exchanging\n");
printf(" s for spatial\n");
printf(" h for Haar wavelets (not supported yet)\n");
printf(" <percent>: percentage used for adaptative thresholding\n");
printf(" Mandatory with the s or h option\n");
printf("\nExample:\n");
printf(" attack orig.ppm water.ppm hsv:v s (D*******)\n");
printf(" attack orig.ppm water.ppm rgb:b s (S******)\n");
printf(" attack orig.ppm water.ppm yuv:y s (S***S***)\n");
}
/*--------------------------------------------------------------------------------*
| This function IFS analyze the command line. |
*--------------------------------------------------------------------------------*/
void analyzeCmd(int argNumber, char **arguments, optionsCmd *cmd){
int i;
/* Check good number of arguments */
if (argNumber != 5 && argNumber != 6) {
fprintf(stderr, "ERROR: Wrong number of arguments\n");
printUsage();
exit(-1);
}
/* Check first argument */
cmd->origFile = (char *)malloc(sizeof(char)*(strlen(arguments[1])+1));
strcpy(cmd->origFile, arguments[1]);
/* Check second argument */
cmd->waterFile = (char *)malloc(sizeof(char)*(strlen(arguments[2])+1));
strcpy(cmd->waterFile, arguments[2]);
/* Check the third argument */
if (strlen(arguments[3])<5 || strlen(arguments[3])>7 || arguments[3][3]!=':'){
fprintf(stderr,"ERROR: Wrong third argument\n");
printUsage();
exit(1);
}
else {
/* Set the colorspace */
if (strncmp(arguments[3],"rgb",3)==0)
cmd->colorSpace = SS_RGB;
else if (strncmp(arguments[3],"yuv",3)==0)
cmd->colorSpace = SS_YUV;
else if (strncmp(arguments[3],"hsv",3)==0)
cmd->colorSpace = SS_HSV;
else if (strncmp(arguments[3],"lab",3)==0)
cmd->colorSpace = SS_LAB;
else if (strncmp(arguments[3],"xyz",3)==0)
cmd->colorSpace = SS_XYZ;
else {
fprintf(stderr,"ERROR: Color space not supported!\n");
printUsage();
exit(1);
}
/* Initialyze the attack with 0 */
cmd->c1_flag = SS_NO_ATTACK;
cmd->c2_flag = SS_NO_ATTACK;
cmd->c3_flag = SS_NO_ATTACK;
/* Looking for channels to attack */
for (i=4;i<(int)strlen(arguments[3]);i++){
if (cmd->colorSpace == SS_RGB){
if (arguments[3][i]=='r')
cmd->c1_flag = SS_ATTACK;
else if (arguments[3][i]=='g')
cmd->c2_flag = SS_ATTACK;
else if (arguments[3][i]=='b')
cmd->c3_flag = SS_ATTACK;
else {
fprintf(stderr,"ERROR: Channel %c does not belong to color space!\n",arguments[3][i]);
printUsage();
exit(1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -