Stabilize clone stamp tracks and sample fractional motion continuously

这个提交包含在:
mac 于 2026-11-06 01:30:28 +08:00 提交
1 父节点 89eeaa9ba1
当前提交 7b6a3106ca
7 个文件已更改
+100 -15

没有与搜索条件相匹配的文件

@@ -124,6 +124,24 @@ if(faceFixture.length){
stamp[@"keys"]=@[DYStampKey(next,moved,YES,1,endMotion)];
Pixels equalZoom=frame(next,@"clone-stamp-equal-scale-production-render");
run.record(@"clone-stamp-equal-zoom-preserves-pixel-exact-copy",pixel(equalZoom,52,38,baseline,24,18)==0);
DYStampMotion subpixel=startMotion;
subpixel.sourceOffsetX=.5f/w;
stamp[@"keys"]=@[DYStampKey(next,p,NO,1,subpixel)];
Pixels atUnit=frame(next,@"clone-stamp-fractional-translation-at-unit-zoom");
subpixel.sourceScaleX=1.0002f;
stamp[@"keys"]=@[DYStampKey(next,p,NO,1,subpixel)];
Pixels nearUnit=frame(next,@"clone-stamp-fractional-translation-near-unit-zoom");
float unitPixel=(baseline[(12*w+16)*4]+baseline[(12*w+17)*4])*.5f;
run.record(@"clone-stamp-fractional-translation-is-continuous-through-unit-zoom",
fabs(atUnit[(24*w+48)*4]-unitPixel)<.0004f&&pixel(atUnit,48,24,nearUnit,48,24)<.0004f);
subpixel.sourceOffsetX=-16.5f/w;
subpixel.sourceScaleX=1;
stamp[@"keys"]=@[DYStampKey(next,p,NO,1,subpixel)];
Pixels atEdge=frame(next,@"clone-stamp-fractional-source-crossing-image-edge");
float edgePixel=(baseline[(12*w)*4]+baseline[(24*w+48)*4])*.5f;
run.record(@"clone-stamp-source-fades-continuously-at-image-edge",
fabs(atEdge[(24*w+48)*4]-edgePixel)<.0005f);
stamp[@"keys"]=@[DYStampKey(next,moved,YES,1,endMotion)];
DYMaskParameters differentTarget=moved;differentTarget.centerY=.45f;
endMotion.sourceScaleX=1.25f;
run.record(@"clone-stamp-retracking-updates-paired-data-without-overwriting-manual-target",
@@ -141,6 +159,31 @@ if(faceFixture.length){
merged&&mergedKeys.count==5&&[mergedKeys[0] isEqual:DYMaskKey(previous,p,NO,1)]&&
[mergedKeys[1] isEqual:pairKeys[0]]&&[mergedKeys[2] isEqual:DYMaskKey(authored,p,YES,1)]&&
[mergedKeys[3] isEqual:pairKeys[1]]&&[mergedKeys[4] isEqual:DYMaskKey(following,p,NO,1)]);
NSMutableArray *jitter=[NSMutableArray array];
for(int i=0;i<7;i++){
DYMaskParameters shape=p;
shape.centerX+=i*.01f+(i==3?.04f:0);
DYStampMotion motion=startMotion;
motion.sourceOffsetY=i*.01f+(i==3?.04f:0);
motion.sourceScaleX=expf(i*.02f+(i==3?.08f:0));
motion.targetScaleY=expf(i*-.02f+(i==3?-.08f:0));
[jitter addObject:DYStampKey(CMTimeMake(i,25),shape,NO,.9f,motion)];
}
stamp[@"keys"]=@[];
BOOL stable=DYMergeTracking(stamp,jitter,frameDuration);
NSArray *smoothed=stamp[@"keys"];
CMTime center=CMTimeMake(3,25);
auto filtered=DYStampMotionAtTime(stamp,center);
float expectedSpike=.04f*6/16;
run.record(@"clone-stamp-smooths-both-positions-and-log-scales-and-keeps-analysis-endpoints",
stable&&smoothed.count==7&&[smoothed.firstObject isEqual:jitter.firstObject]&&
[smoothed.lastObject isEqual:jitter.lastObject]&&
fabs(DYMaskAtTime(stamp,center).centerX-p.centerX-.03f-expectedSpike)<1e-6&&
fabs(filtered.sourceOffsetY-.03f-expectedSpike)<1e-6&&
fabs(logf(filtered.sourceScaleX)-.09f)<1e-6&&fabs(logf(filtered.targetScaleY)+.09f)<1e-6);
stamp[@"keys"]=@[];
stable=DYMergeTracking(stamp,jitter.reverseObjectEnumerator.allObjects,frameDuration);
run.record(@"clone-stamp-smoothing-is-independent-of-analysis-direction",stable&&[stamp[@"keys"] isEqual:smoothed]);
stamp[@"enabled"]=@NO;Pixels disabled=frame(next,@"clone-stamp-disabled-render");
run.record(@"clone-stamp-disabled-is-identical",difference(disabled,baseline).maximum==0);
stamp[@"enabled"]=@YES;NSError *failure=nil;