code wiki / (root) / nx_imgxform.nx

nx_imgxform.nx

buildroot/runtime/nx_imgxform.nx

11274 B303 linesdepth 3pulls 3 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_imgxform.nx -- DETERMINISTIC IMAGE-TRANSFORMATION BATTERY: the adversary set a reverse-image engine must survive. TinEye's product claim is that it finds "modified versions" of an image -- resized, cropped, edited, colour-adjusted, watermarked. You cannot honestly say how close we are to that without APPLYING those modifications and MEASURING what survives. This organ is that adversary: 16 named transformation classes, pure integer, zero float, bit-reproducible (fixed LCG seed), each a pure function grayscale(w,h) -> grayscale(w2,h2). It deliberately holds NO ranking or hashing logic -- it only DEFORMS. nx_imgbench does the measuring, nx_phash/nx_visdesc do the describing. Single responsibility: this file's one job is "make a modified copy of an image, the way the real world modifies images". The classes are chosen from what actually happens to an image on the open web (and therefore what TinEye/Google/Yandex are judged on): CDN rescaling, thumbnail generation, re-encoding artifacts, editorial cropping, letterboxing into a fixed aspect, mirroring, EXIF-rotation, brightness/contrast "enhancement", additive sensor/compression noise, and watermark/caption bars. license_tier: ORIGINAL

dependencies 1 imports · 2 importers

syscalls.nx nx_imgxform.nx nx_imgbench.nx nx_imgsearch_engine_gate.nx

imports: syscalls.nx

imported by: nx_imgbench.nxnx_imgsearch_engine_gate.nx

structs

none

consts

19const XF_IDENT: i64 = 0
20const XF_SCALE50: i64 = 1
21const XF_SCALE200: i64 = 2
22const XF_BRIGHT_UP: i64 = 3
23const XF_BRIGHT_DN: i64 = 4
24const XF_CONTRAST: i64 = 5
25const XF_CROP10: i64 = 6
26const XF_CROP20: i64 = 7
27const XF_CROP30: i64 = 8
28const XF_PAD10: i64 = 9
29const XF_FLIPH: i64 = 10
30const XF_ROT90: i64 = 11
31const XF_ROT180: i64 = 12
32const XF_NOISE: i64 = 13
33const XF_WATERMARK: i64 = 14
34const XF_BLOCKQ: i64 = 15
35const XF_CROPSCALE: i64 = 16 // crop the centre THEN rescale it back to full size = occlusion + SCALE
36const XF_COUNT: i64 = 17
38const XF_NOISE_AMP: i64 = 12 // +/- grey levels of additive noise (heavy-recompression scale)
39const XF_BRIGHT_D: i64 = 40 // brightness offset applied by XF_BRIGHT_UP / XF_BRIGHT_DN
40const XF_WM_ROWPCT: i64 = 85 // watermark/caption bar starts at this percent of image height
41const XF_WM_LEVEL: i64 = 235 // watermark bar grey level (near-white caption bar)
42const XF_QSTEP: i64 = 16 // XF_BLOCKQ quantisation step (coarse-JPEG proxy)

functions

44func xf_clamp(v: i64) -> i64 { if v < 0 { return 0 } if v > 255 { return 255 } return v }
called by 2: xf_blockqxf_apply
47func xf_rng(s: *i64) -> i64 { let x: i64 = s[0] * 0x5851F42D4C957F2D + 0x14057B7EF767814F; s[0] = x; return x }
called by 1: xf_apply
50func xf_name(kind: i64) -> *u8
called by 1: main
72func xf_resample(gray: *u8, w: i64, h: i64, out: *u8, dw: i64, dh: i64) -> i64
called by 1: xf_apply
88func xf_crop(gray: *u8, w: i64, h: i64, keep_pct: i64, outwh: *i64) -> *u8
called by 1: xf_apply
108func xf_pad(gray: *u8, w: i64, h: i64, pct: i64, outwh: *i64) -> *u8
called by 1: xf_apply
130func xf_blockq(gray: *u8, w: i64, h: i64, out: *u8) -> i64
called by 1: xf_apply calls 1: xf_clamp
175func xf_apply(kind: i64, gray: *u8, w: i64, h: i64, outwh: *i64) -> *u8