nx_imgxform.nx
buildroot/runtime/nx_imgxform.nx
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
imports: syscalls.nx
imported by: nx_imgbench.nxnx_imgsearch_engine_gate.nx
structs
| none |
consts
| 19 | const XF_IDENT: i64 = 0 |
| 20 | const XF_SCALE50: i64 = 1 |
| 21 | const XF_SCALE200: i64 = 2 |
| 22 | const XF_BRIGHT_UP: i64 = 3 |
| 23 | const XF_BRIGHT_DN: i64 = 4 |
| 24 | const XF_CONTRAST: i64 = 5 |
| 25 | const XF_CROP10: i64 = 6 |
| 26 | const XF_CROP20: i64 = 7 |
| 27 | const XF_CROP30: i64 = 8 |
| 28 | const XF_PAD10: i64 = 9 |
| 29 | const XF_FLIPH: i64 = 10 |
| 30 | const XF_ROT90: i64 = 11 |
| 31 | const XF_ROT180: i64 = 12 |
| 32 | const XF_NOISE: i64 = 13 |
| 33 | const XF_WATERMARK: i64 = 14 |
| 34 | const XF_BLOCKQ: i64 = 15 |
| 35 | const XF_CROPSCALE: i64 = 16 // crop the centre THEN rescale it back to full size = occlusion + SCALE |
| 36 | const XF_COUNT: i64 = 17 |
| 38 | const XF_NOISE_AMP: i64 = 12 // +/- grey levels of additive noise (heavy-recompression scale) |
| 39 | const XF_BRIGHT_D: i64 = 40 // brightness offset applied by XF_BRIGHT_UP / XF_BRIGHT_DN |
| 40 | const XF_WM_ROWPCT: i64 = 85 // watermark/caption bar starts at this percent of image height |
| 41 | const XF_WM_LEVEL: i64 = 235 // watermark bar grey level (near-white caption bar) |
| 42 | const XF_QSTEP: i64 = 16 // XF_BLOCKQ quantisation step (coarse-JPEG proxy) |
functions
| 44 | func xf_clamp(v: i64) -> i64 { if v < 0 { return 0 } if v > 255 { return 255 } return v } |
| 47 | func xf_rng(s: *i64) -> i64 { let x: i64 = s[0] * 0x5851F42D4C957F2D + 0x14057B7EF767814F; s[0] = x; return x } called by 1: xf_apply |
| 50 | func xf_name(kind: i64) -> *u8 called by 1: main |
| 72 | func xf_resample(gray: *u8, w: i64, h: i64, out: *u8, dw: i64, dh: i64) -> i64 called by 1: xf_apply |
| 88 | func xf_crop(gray: *u8, w: i64, h: i64, keep_pct: i64, outwh: *i64) -> *u8 called by 1: xf_apply |
| 108 | func xf_pad(gray: *u8, w: i64, h: i64, pct: i64, outwh: *i64) -> *u8 called by 1: xf_apply |
| 130 | func xf_blockq(gray: *u8, w: i64, h: i64, out: *u8) -> i64 |
| 175 | func xf_apply(kind: i64, gray: *u8, w: i64, h: i64, outwh: *i64) -> *u8 |