資源簡介
利用MATLAB程序?qū)Σ煌瑫r間的兩張圖片進行變化檢測,找出其中的變化部分

代碼片段和文件信息
/*?salient?region?detection
?*?image?format:?raw?PGM
?*
?*?described?in:
?*?A?Simple?Method?for?Detecting?Salient?Regions
?*?Paul?L.?Rosin
?*?Pattern?Recognition?vol.?42?no.?11?pp.?2363-2371?2009.
?*
?*?Paul?Rosin
?*?September?2007
?*/
#include?
#include?
#include?
#ifndef?FALSE
#?define?FALSE?0
#?define?TRUE?(!FALSE)
#endif
#define?SQR(x)??????????((x)*(x))
#define?MAX_SIZE?2000
#include?“pgmio.h“
int?kernel[3][3]?=?{{121}?{000}?{-1-2-1}};
unsigned?char?image[MAX_SIZE][MAX_SIZE];
int?dt_image[MAX_SIZE][MAX_SIZE];
unsigned?char?tmp[MAX_SIZE][MAX_SIZE];
unsigned?char?thresh[MAX_SIZE][MAX_SIZE];
double?edges[MAX_SIZE][MAX_SIZE];
double?summed_dt[MAX_SIZE][MAX_SIZE];
int?heightwidthdepth;
main(argcargv)
int?argc;
char?*argv[];
{
????int?itxy;
????char?*infile*outfile*maskfile*saliencyfile;
????infile?=?outfile?=?maskfile?=?saliencyfile?=?NULL;
????/*?parse?command?line?*/
????for(i?=?1;?i?????????if?(argv[i][0]?==?‘-‘)?{
????????????switch(argv[i][1])?{
????????????????case?‘i‘:
????????????????????i++;
????????????????????infile?=?argv[i];
????????????????????break;
????????????????case?‘m‘:
????????????????????i++;
????????????????????maskfile?=?argv[i];
????????????????????break;
????????????????case?‘o‘:
????????????????????i++;
????????????????????outfile?=?argv[i];
????????????????????break;
????????????????case?‘s‘:
????????????????????i++;
????????????????????saliencyfile?=?argv[i];
????????????????????break;
????????????????default:
????????????????????printf(“unknown?option?%s\n“argv[i]);
????????????????????options(argv[0]);
????????????}
????????}
????????else?{
????????????printf(“unknown?option?%s\n“argv[i]);
????????????options(argv[0]);
????????}
????}
????if?((infile?==?NULL)?||?(outfile?==?NULL))
????????options(argv[0]);
????read_pgm(imageinfile&width&height&depth);
????sobel(imageedges);
????/*?for?consistency?with?my?original?implementation
???????I?rescale?and?copy?the?edges?into?an?8?bit?image
????*/
????rescale(edgestmp);
????for?(y?=?0;?y?????????for?(x?=?0;?x?????????????summed_dt[x][y]?=?0;
????for?(t?=?4;?t?255;?t?+=?4)?{
????????//?threshold
????????for?(y?=?0;?y?????????????for?(x?=?0;?x?????????????????if?(tmp[x][y]?>?t)
????????????????????thresh[x][y]?=?0;
????????????????else
????????????????????thresh[x][y]?=?255;
????????//?perform?DT
????????dt(threshdt_image);
????????//?running?DT?sum
????????for?(y?=?0;?y?????????????for?(x?=?0;?x?????????????????summed_dt[x][y]?+=?dt_image[x][y];
????}
????/*?set?corners?to?average?for?the?time?being?*/
????summed_dt[0][0]?=?(summed_dt[1][0]?+?summed_dt[0][1])?/?2;
????summed_dt[0][height-1]?=?(summed_dt[1][height-1]?+?summed_dt[0][height-2])?/?2;
????summed_dt[width-1][0]?=?(summed_dt[width-2][0]?+?summed_dt[width-1][1])?/?2;
????summed_dt[width-1][height-1]?=?(summed_dt[width-2][height-1]?+?summe
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????154416??2007-09-24?10:26??19021.pgm
?????文件??????????80??2007-09-24?10:29??Makefile
?????文件????????2383??2009-08-05?17:34??pgmio.h
?????文件????????1304??2009-08-28?13:11??README
?????文件???????10140??2009-08-28?13:12??salient_regions.c
- 上一篇:基于OLS 算法完成MG 時間序列問題
- 下一篇:模4可逆計數(shù)器
評論
共有 條評論