目录
代码及简单说明
什么是MTF, SFR
Mitre SFR 1.4代码组成
如何编译
如何使用
出现的错误及解决办法
1. 错误 fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
2. fatal error C1083: Cannot open include file: 'libgen.h': No such file or directory
3. error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead.
4. error C4996: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details.
5. 【重点】最简单的解决办法
成功运行截图
【图像处理】SFR算法详解1
https://blog.csdn.net/jaych/article/details/50889664
【图像处理】SFR算法详解2
https://blog.csdn.net/jaych/article/details/50700576
【图像处理】SFR算法详解3
https://blog.csdn.net/jaych/article/details/51030939
【图像处理】SFR算法详解4
https://blog.csdn.net/jaych/article/details/51031064
在ReadMe.txt中:
mitre_sfr.c | The wrapper/main code |
sfr_iso.c | the derived ISO code;Code predominantly modified from IS 12233:2000 Annex A |
find_area.c | The auto-refinement code |
代码链接:
http://www2.mitre.org/tech/mtf/sfr.zip
在ReadMe.txt中
This code is compiled with LIBTIFF. Once libtiff is installed
compile the code in this directory using 'make'.
(If necessary add additional LDFLAGS to identify library locations.)
Open a terminal and
> cd
> make
请参考In-Out.doc。在控制台运行SFR_1.4.2.exe,红色标记的为控制台输入部分
SFR version 1.4.2
a Compute edge tilt angle from user entered points
b Auto-refine input region
c ROI defined by center point instead of UL corner
d Create diagnostic image (_box.pgm)
e Verbose output
f Reverse image polarity
h Help & Program Notice
n Don't compare output to PIV spec
Enter run options...or...Press RETURN if none: Enter(回车)
Enter image filename: Edge.pgm
OECF: if nonlinear enter filename, if linear press RETURN oecf.txt
Enter pixels per inch (PPI): 500
(ref: col,row = 0,0 at upper left corner of ENTIRE image,
cols increase left to right, rows increase top to bottom.)
Enter Col, Row for UL pixel of ROI: 130 66
Enter Width, Height for region of interest: 120 260
解决办法:包含这个头文件是使用到chdir()这个函数功能
unistd.h是linux下的,windows不支持linux的系统调用。
头文件unistd.h是Linux/Unix的系统调用,包含了许多UNIX系统服务函数原型,如open、read、write、_exit、getpid等函数。在linux下能够编译通过的包含此头文件的程序,在VS下编译时出现了如下问题
fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
只要在默认库文件夹下(我的电脑是 c:\program files (x86)\microsoft visual studio 12.0\vc\include\)添加一个unistd.h文件即可,其内容如下:
#ifndef _UNISTD_H
#define _UNISTD_H
#include
#include
#endif/* _UNISTD_H */
这样在重新编译包含unis.h的程序就能通过了
参考
https://stackoverflow.com/questions/22705751/cannot-open-include-file-unistd-h-no-such-file-or-directory
https://stackoverflow.com/questions/2793413/unistd-h-related-difficulty-when-compiling-bison-flex-program-under-vc/2872995#2872995
包含这个头文件就使用到dirname()一个函数:用来获取文件夹名称
解决办法
Step#1
dirname是Unix/Linux下的函数,Windows平台是没有的,参考Stack Overflow上的建议,
使用Windows下的函数 _splitpath_s自己简单实现了一个dirname()【可以使用,待后续完善】
Visual Studio does neither have this header nor these functions. If using _splitpath_s, _wsplitpath_s isn't an option, then you have to write them by yourself.
参考链接:https://stackoverflow.com/questions/30564944/cannot-open-include-file-libgen-h
Step#2 dirname()代码
// crt_makepath_s.c
#include //_splitpath_s, _makepath_s
#include //printf
char finalDirName[_MAX_DIR]; //最终返回的文件夹名称
char * dirname(char * fullpath)
{
char drive[_MAX_DRIVE]; //路径中的盘符,例如"d:"
char dir[_MAX_DIR]; //文件夹,例如"\sample\crt\"
char fname[_MAX_FNAME]; //文件名称,例如"crt_makepath_s"
char ext[_MAX_EXT]; //文件扩展名,例如".c"
errno_t err;
err = _splitpath_s(fullpath, drive, _MAX_DRIVE, dir, _MAX_DIR, fname,
_MAX_FNAME, ext, _MAX_EXT); //拆分路径
if (err != 0)
{
printf("Error splitting the path. Error code %d.\n", err);
exit(1);
}
sprintf(finalDirName, "%s%s", drive, dir); //文件夹全路径,例如"d:\sample\crt\"
printf("DirName: %s\n", finalDirName);
return finalDirName;
}
int main(int argc, char **argv)
{
char *fnamep;
fnamep = dirname(argv[0]);
printf("Custome Dir:%s\n", fnamep);
return 0;
}
关于_splitpath_s
的说明与范例代码可以参考如下Microsoft官网说明
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/splitpath-s-wsplitpath-s?view=vs-2019
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/makepath-s-wmakepath-s?view=vs-2019
To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\stdio.h(211) : see declaration of 'fopen'
其他类似错误:
error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
在预处理器中添加“_CRT_SECURE_NO_WARNINGS”
打开工程文件的属性->c/c++->预处理器->预处理器定义 中添加:
【DEBUG模式下】
_CRT_SECURE_NO_WARNINGS
_CRT_NONSTDC_NO_DEPRECATE
【RELEASE 模式下】
_CRT_SECURE_NO_WARNINGS
_CRT_NONSTDC_NO_DEFPRECATES
参考网址:https://blog.csdn.net/u010368556/article/details/79344265
后来仔细观察代码,发现只要做这简单的两步即可。前面1-4可以不用看了。
1. mitre_sfr.c在“#if !defined(MSDOS)”前面添加下面几句宏定义即可
#ifndef MSDOS
#define MSDOS
#endif
2. 打开工程文件的属性->c/c++->预处理器->预处理器定义 中添加:
_CRT_SECURE_NO_WARNINGS