File size: 4,614 Bytes
b5af7d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, {useState} from 'react';
import {createRoot} from 'react-dom/client';
import './style.css';
import ReviewSummary from './ReviewSummary';
import {requestAlignment} from './api';

function App(){
  const [result,setResult]=useState(null), [busy,setBusy]=useState(false), [error,setError]=useState('');
  const [view,setView]=useState('overlay'), [native,setNative]=useState(false);
  const [engine,setEngine]=useState('classical');
  async function submit(e){
    e.preventDefault(); const data=new FormData(e.currentTarget);
    data.set('exposure',data.get('exposure') ? 'true' : 'false');
    data.set('local',engine === 'learned' || data.get('local') ? 'true' : 'false');
    data.set('iris_crop_confirmed',data.get('iris_crop_confirmed') ? 'true' : 'false');
    setBusy(true);setError('');setResult(null);
    try{const body=await requestAlignment(data);setResult(body);setView(body.metrics.status === 'unaligned' ? 'reference' : 'overlay');}
    catch(err){setError(err.message);}finally{setBusy(false);}
  }
  return <main><header><span>COMPUTER VISION / REGISTRATION REVIEW</span><h1>Iris registration lab</h1><p>Align source photographs. Inspect the detail. Keep the reference in control.</p></header>
    <div className="layout"><aside><form onSubmit={submit}><h2>Image pair</h2><p>Use tight iris crops with the entire iris visible. Choose the better-exposed photograph as reference.</p>
    <label>Alignment mode<select name="engine" value={engine} onChange={e=>setEngine(e.target.value)}><option value="classical">Standard</option><option value="learned">Learned iris alignment (experimental)</option></select></label>
    {engine === "learned" && <label className="check"><input name="iris_crop_confirmed" type="checkbox" required/> Both inputs are equally sized square crops, centered on the iris (400–3000 pixels). This mode requires review.</label>}
    <label>01 · Reference photograph<input name="reference" type="file" accept="image/jpeg,image/png" required /></label>
    <label>02 · Moving photograph<input name="moving" type="file" accept="image/jpeg,image/png" required /></label>
    <label className="check"><input name="exposure" type="checkbox" defaultChecked/> Lift darker image exposure</label>
    {engine === "classical" && <label className="check"><input name="local" type="checkbox" defaultChecked/> Constrained local refinement</label>}
    <button disabled={busy}>{busy?'Aligning photographs…':'Run alignment'}</button></form>
    <p className="note">Source-image detail only. Every valid pair receives a review. If alignment is unreliable, the reference is preserved and both originals remain available.</p>
    <p className="note">Local POC · 25 MB / 30 MP per image. Outputs are returned in memory; refresh clears the review.</p><a href="/benchmark/" target="_blank" rel="noreferrer">View synthetic benchmark report ↗</a>
    {error && <p role="alert" className="error">{error}</p>}
    {result && <ReviewSummary metrics={result.metrics}/>}
    </aside><section className="workspace"><div className="toolbar"><select aria-label="Output view" value={view} onChange={e=>setView(e.target.value)}>{(result ? Object.keys(result.images) : ['overlay']).map(x=><option key={x}>{x}</option>)}</select><label className="check"><input type="checkbox" checked={native} onChange={e=>setNative(e.target.checked)}/>100% pixels</label>{result && <a download={view+'.png'} href={result.images[view]}>Download PNG</a>}</div>
    {result?.metrics.status === 'unaligned' && <div className="originals"><figure><img src={result.images.reference} alt="Reference original"/><figcaption>Reference — unchanged</figcaption></figure><figure><img src={result.images.moving} alt="Second original, not aligned"/><figcaption>Second original — not aligned</figcaption></figure></div>}
    <div className={'canvas '+(native?'native':'')}>{result?<img src={result.images[view]} alt={view+' registration output'}/>:<div className="empty"><div>◎</div><h2>Make the structures match.</h2><p>Upload two photographs to inspect alignment overlays and source-only output.</p><small>Synthetic tests establish code behavior, not real-eye accuracy.</small></div>}</div>
    <p className="note">Overlay: doubled fibers indicate misalignment. Contribution: black = reference only, lighter areas include the moving photograph (maximum 50%). Composite is experimental. Local confidence: white = eligible for blending, not verified anatomy. Deformation: brightness shows local movement (12 levels per pixel).</p></section></div></main>;
}
createRoot(document.getElementById('root')).render(<App/>);