Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
c028691d
P
pbrt-v4
项目概览
imjiangjun
/
pbrt-v4
12 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pbrt-v4
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c028691d
编写于
10月 26, 2021
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
imgtool: more metadata plumbing
Also, add a color space check to checkImageCompatibility().
上级
47bbab0a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
59 addition
and
60 deletion
+59
-60
src/pbrt/cmd/imgtool.cpp
src/pbrt/cmd/imgtool.cpp
+59
-60
未找到文件。
src/pbrt/cmd/imgtool.cpp
浏览文件 @
c028691d
...
...
@@ -311,6 +311,43 @@ int help(std::vector<std::string> args) {
return
0
;
}
static
bool
checkImageCompatibility
(
std
::
string
fn1
,
const
Image
&
im1
,
const
RGBColorSpace
*
cs1
,
std
::
string
fn2
,
const
Image
&
im2
,
const
RGBColorSpace
*
cs2
)
{
if
(
im1
.
Resolution
()
!=
im2
.
Resolution
())
{
fprintf
(
stderr
,
"%s: image resolution (%d, %d) doesn't match
\"
%s
\"
(%d, %d).
\n
"
,
fn1
.
c_str
(),
im1
.
Resolution
().
x
,
im1
.
Resolution
().
y
,
fn2
.
c_str
(),
im2
.
Resolution
().
x
,
im2
.
Resolution
().
y
);
return
false
;
}
if
(
im1
.
NChannels
()
!=
im2
.
NChannels
())
{
fprintf
(
stderr
,
"%s: image channel count %d doesn't match
\"
%s
\"
, %d.
\n
"
,
fn1
.
c_str
(),
im1
.
NChannels
(),
fn2
.
c_str
(),
im2
.
NChannels
());
return
false
;
}
if
(
im1
.
ChannelNames
()
!=
im2
.
ChannelNames
())
{
auto
print
=
[](
const
std
::
vector
<
std
::
string
>
&
n
)
{
std
::
string
s
=
n
[
0
];
for
(
size_t
i
=
1
;
i
<
n
.
size
();
++
i
)
{
s
+=
", "
;
s
+=
n
[
i
];
}
return
s
;
};
fprintf
(
stderr
,
"%s: warning: image channel names
\"
%s
\"
don't match
\"
%s
\"
"
"with
\"
%s
\"
.
\n
"
,
fn1
.
c_str
(),
print
(
im1
.
ChannelNames
()).
c_str
(),
fn2
.
c_str
(),
print
(
im2
.
ChannelNames
()).
c_str
());
}
if
(
*
cs1
!=
*
cs2
)
{
fprintf
(
stderr
,
"%s: color space does not match
\"
%s
\"
.
\n
"
,
fn1
.
c_str
(),
fn2
.
c_str
());
return
false
;
}
return
true
;
}
int
makesky
(
std
::
vector
<
std
::
string
>
args
)
{
std
::
string
outfile
;
Float
albedo
=
0.5
;
...
...
@@ -576,16 +613,13 @@ int splitn(std::vector<std::string> args) {
for
(
const
std
::
string
&
file
:
infiles
)
{
ImageAndMetadata
im
=
Image
::
Read
(
file
);
Image
&
image
=
im
.
image
;
if
(
!
images
.
empty
())
{
if
(
image
.
Resolution
()
!=
images
.
front
().
Resolution
())
{
fprintf
(
stderr
,
"%s: image resolution mismatch.
\n
"
,
file
.
c_str
());
return
1
;
}
if
(
image
.
NChannels
()
!=
images
.
front
().
NChannels
())
{
fprintf
(
stderr
,
"%s: image channel count mismatch.
\n
"
,
file
.
c_str
());
return
1
;
}
}
if
(
!
colorSpace
)
colorSpace
=
im
.
metadata
.
GetColorSpace
();
else
if
(
!
checkImageCompatibility
(
infiles
[
0
],
images
.
front
(),
colorSpace
,
file
,
image
,
im
.
metadata
.
GetColorSpace
()))
return
false
;
images
.
push_back
(
image
);
}
...
...
@@ -828,43 +862,6 @@ int cat(std::vector<std::string> args) {
return
0
;
}
static
bool
checkImageCompatibility
(
const
std
::
string
&
fn1
,
const
Image
&
im1
,
const
std
::
string
&
fn2
,
const
Image
&
im2
)
{
if
(
im1
.
Resolution
()
!=
im2
.
Resolution
())
{
fprintf
(
stderr
,
"%s: image resolution (%d, %d) doesn't match
\"
%s
\"
(%d, %d)."
,
fn1
.
c_str
(),
im1
.
Resolution
().
x
,
im1
.
Resolution
().
y
,
fn2
.
c_str
(),
im2
.
Resolution
().
x
,
im2
.
Resolution
().
y
);
return
false
;
}
if
(
im1
.
NChannels
()
!=
im2
.
NChannels
())
{
fprintf
(
stderr
,
"%s: image channel count %d doesn't match
\"
%s
\"
, %d."
,
fn1
.
c_str
(),
im1
.
NChannels
(),
fn2
.
c_str
(),
im2
.
NChannels
());
return
false
;
}
if
(
im1
.
ChannelNames
()
!=
im2
.
ChannelNames
())
{
auto
print
=
[](
const
std
::
vector
<
std
::
string
>
&
n
)
{
std
::
string
s
=
n
[
0
];
for
(
size_t
i
=
1
;
i
<
n
.
size
();
++
i
)
{
s
+=
", "
;
s
+=
n
[
i
];
}
return
s
;
};
fprintf
(
stderr
,
"%s: warning: image channel names
\"
%s
\"
don't match
\"
%s
\"
"
"with
\"
%s
\"
."
,
fn1
.
c_str
(),
print
(
im1
.
ChannelNames
()).
c_str
(),
fn2
.
c_str
(),
print
(
im2
.
ChannelNames
()).
c_str
());
}
#if 0
if (*md1.GetColorSpace() != *md2.GetColorSpace())
fprintf(stderr, "%s: warning: : computing difference of images with different "
"color spaces!");
#endif
return
true
;
}
int
average
(
std
::
vector
<
std
::
string
>
args
)
{
std
::
string
avgFile
,
filenameBase
;
...
...
@@ -895,6 +892,7 @@ int average(std::vector<std::string> args) {
// Compute average image
ThreadLocal
<
Image
>
avgImages
;
ThreadLocal
<
const
RGBColorSpace
*>
colorSpaces
;
std
::
atomic
<
bool
>
failed
{
false
};
ParallelFor
(
0
,
filenames
.
size
(),
[
&
](
size_t
i
)
{
...
...
@@ -902,9 +900,11 @@ int average(std::vector<std::string> args) {
Image
&
im
=
imRead
.
image
;
Image
&
avg
=
avgImages
.
Get
();
if
(
avg
.
Resolution
()
==
Point2i
(
0
,
0
))
if
(
avg
.
Resolution
()
==
Point2i
(
0
,
0
))
{
avg
=
Image
(
PixelFormat
::
Float
,
im
.
Resolution
(),
im
.
ChannelNames
());
else
if
(
!
checkImageCompatibility
(
filenames
[
i
],
im
,
filenames
[
0
],
avg
))
{
colorSpaces
.
Get
()
=
imRead
.
metadata
.
GetColorSpace
();
}
else
if
(
!
checkImageCompatibility
(
filenames
[
i
],
im
,
imRead
.
metadata
.
GetColorSpace
(),
filenames
[
0
],
avg
,
colorSpaces
.
Get
()))
{
failed
=
true
;
return
;
}
...
...
@@ -943,7 +943,14 @@ int average(std::vector<std::string> args) {
}
});
CHECK
(
avgImage
.
Write
(
avgFile
));
ImageMetadata
avgMetadata
;
colorSpaces
.
ForAll
([
&
](
const
RGBColorSpace
*
cs
)
{
// Will redundantly set it, but whatever.
avgMetadata
.
colorSpace
=
cs
;
});
if
(
!
avgImage
.
Write
(
avgFile
,
avgMetadata
))
return
1
;
return
0
;
}
...
...
@@ -1163,17 +1170,9 @@ int diff(std::vector<std::string> args) {
image
=
image
.
Crop
(
Bounds2i
({
cropWindow
[
0
],
cropWindow
[
2
]},
{
cropWindow
[
1
],
cropWindow
[
3
]}));
if
(
image
.
Resolution
()
!=
refImage
.
Resolution
())
{
fprintf
(
stderr
,
"%s: image resolution (%d, %d) doesn't match reference (%d, %d)
\n
"
,
imageFile
.
c_str
(),
image
.
Resolution
().
x
,
image
.
Resolution
().
y
,
refImage
.
Resolution
().
x
,
refImage
.
Resolution
().
y
);
if
(
!
checkImageCompatibility
(
imageFile
,
image
,
im
.
metadata
.
GetColorSpace
(),
referenceFile
,
refImage
,
refMetadata
.
GetColorSpace
()))
return
1
;
}
if
(
*
im
.
metadata
.
GetColorSpace
()
!=
*
refMetadata
.
GetColorSpace
())
fprintf
(
stderr
,
"Warning: computing difference of images with different "
"color spaces!"
);
// Clamp Infs
int
nClamped
=
0
,
nRefClamped
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录