DIRECTORY ImagerPixelMaps, ImagerFrameBuffer, AIS, Rope; AISTest: CEDAR PROGRAM IMPORTS ImagerPixelMaps, ImagerFrameBuffer, AIS, Rope ~ BEGIN ROPE: TYPE ~ Rope.ROPE; Show: PROC [name: ROPE] ~ TRUSTED { colorDisplay: ImagerPixelMaps.PixelMap _ ImagerFrameBuffer.GrayScaleDisplay8[]; ais: AIS.FRef _ AIS.OpenFile[name]; window: AIS.WRef _ AIS.OpenWindow[ais]; lineMap: ImagerPixelMaps.PixelMap _ ImagerPixelMaps.Create[3, [window.GetWindowParams.firstScan, window.GetWindowParams.firstPixel, 1, window.GetWindowParams.lastPixel+1-window.GetWindowParams.firstPixel]]; lineBufferDesc: AIS.Buffer _ [length: lineMap.refRep.words, addr: lineMap.refRep.pointer]; FOR i: NAT IN [window.GetWindowParams.firstScan..window.GetWindowParams.lastScan] DO AIS.UnsafeReadLine[window, lineBufferDesc, i]; colorDisplay.Transfer[lineMap]; lineMap.sOrigin _ lineMap.sOrigin + 1; ENDLOOP; }; Invert: PROC [name: ROPE] ~ TRUSTED { colorDisplay: ImagerPixelMaps.PixelMap _ ImagerFrameBuffer.GrayScaleDisplay8[]; ais: AIS.FRef _ AIS.OpenFile[name: name, write: TRUE]; window: AIS.WRef _ AIS.OpenWindow[ais]; BufferRep: TYPE ~ RECORD [SEQUENCE length: NAT OF WORD]; lineBuffer: REF BufferRep _ NEW[BufferRep[(window.GetWindowParams.lastPixel+1-window.GetWindowParams.firstPixel+1)/2]]; lineBufferDesc: AIS.Buffer _ [length: lineBuffer.length, addr: @(lineBuffer[0])]; FOR i: NAT IN [window.GetWindowParams.firstScan..window.GetWindowParams.lastScan] DO AIS.UnsafeReadLine[window, lineBufferDesc, i]; FOR j: NAT IN [0..lineBuffer.length) DO lineBuffer[j] _ LAST[CARDINAL]-lineBuffer[j]; ENDLOOP; AIS.UnsafeWriteLine[window, lineBufferDesc, i]; ENDLOOP; AIS.CloseFile[ais]; }; Reduce: PROC [name: ROPE] ~ TRUSTED { colorDisplay: ImagerPixelMaps.PixelMap _ ImagerFrameBuffer.GrayScaleDisplay8[]; ais: AIS.FRef _ AIS.OpenFile[name: name]; output: AIS.FRef _ AIS.CreateFile[name: name, raster: HalfRaster[AIS.ReadRaster[ais]]]; HalfRaster: PROC [raster: AIS.Raster] RETURNS [AIS.Raster] ~ CHECKED { raster.scanCount _ raster.scanCount/2; raster.scanLength _ raster.scanLength/2; IF raster.bitsPerPixel # 8 THEN ERROR; RETURN [raster] }; window: AIS.WRef _ AIS.OpenWindow[ais]; outputWindow: AIS.WRef _ AIS.OpenWindow[output]; BufferRep: TYPE ~ PACKED ARRAY [0..3000) OF [0..256); nPerLine: NAT _ window.GetWindowParams.lastPixel+1-window.GetWindowParams.firstPixel; waste: NAT _ 3000-nPerLine; lineBuffer1: REF BufferRep _ NEW[BufferRep]; lineBuffer2: REF BufferRep _ NEW[BufferRep]; lineBuffer1Desc: AIS.Buffer _ [length: SIZE[BufferRep], addr: BASE[lineBuffer1^]]; lineBuffer2Desc: AIS.Buffer _ [length: SIZE[BufferRep], addr: BASE[lineBuffer2^]]; AIS.WriteComment[output, AIS.ReadComment[ais].Concat[" Reduced 50%"]]; AIS.WritePhotometry[output, AIS.ReadPhotometry[ais], AIS.ReadHistogram[ais]]; FOR i: NAT IN [0..outputWindow.GetWindowParams.lastScan] DO AIS.UnsafeReadLine[window, lineBuffer1Desc, 2*i]; AIS.UnsafeReadLine[window, lineBuffer2Desc, MIN[2*i+1, window.GetWindowParams.lastScan]]; FOR j: NAT IN [0..nPerLine/2) DO j2Next: NAT ~ MIN[2*j+1, nPerLine-1]; lineBuffer1[j] _ (CARDINAL[lineBuffer1[2*j]] + lineBuffer1[j2Next] + lineBuffer2[2*j] + lineBuffer2[j2Next])/4 ; ENDLOOP; AIS.UnsafeWriteLine[outputWindow, lineBuffer1Desc, i]; ENDLOOP; AIS.CloseFile[ais]; AIS.CloseFile[output]; }; Rotate: PROC [name: ROPE] ~ TRUSTED { ais: AIS.FRef _ AIS.OpenFile[name: name]; output: AIS.FRef _ AIS.CreateFile[name: name, raster: RotatedRaster[AIS.ReadRaster[ais]]]; RotatedRaster: PROC [raster: AIS.Raster] RETURNS [AIS.Raster] ~ CHECKED { t: CARDINAL; IF raster.bitsPerPixel # 8 OR raster.scanMode # rd THEN ERROR; raster.scanMode _ dr; t _ raster.scanCount; raster.scanCount _ raster.scanLength; raster.scanLength _ (t+1)/2*2; -- make even to satisfy a SirPress.UnsafeShowLine restriction RETURN [raster] }; window: AIS.WRef _ AIS.OpenWindow[ais]; outputWindow: AIS.WRef _ AIS.OpenWindow[output]; BufferRep: TYPE ~ PACKED ARRAY [0..500) OF [0..256); nPerLine: NAT _ window.GetWindowParams.lastPixel+1-window.GetWindowParams.firstPixel; waste: NAT _ 500-nPerLine; image: ARRAY [0..500) OF REF BufferRep; lineBuffer: REF BufferRep _ NEW[BufferRep]; lineBufferDesc: AIS.Buffer _ [length: SIZE[BufferRep], addr: BASE[lineBuffer^]]; AIS.WriteComment[output, AIS.ReadComment[ais].Concat[" Rotated scan direction"]]; AIS.WritePhotometry[output, AIS.ReadPhotometry[ais], AIS.ReadHistogram[ais]]; FOR s: NAT IN [0..outputWindow.GetWindowParams.lastScan] DO image[s] _ NEW[BufferRep]; image[s][outputWindow.GetWindowParams.lastPixel] _ 0; ENDLOOP; FOR s: NAT IN [0..window.GetWindowParams.lastScan] DO AIS.UnsafeReadLine[window, lineBufferDesc, s]; FOR p: NAT IN [0..window.GetWindowParams.lastPixel] DO image[p][s] _ lineBuffer[p]; ENDLOOP; ENDLOOP; FOR s: NAT IN [0..outputWindow.GetWindowParams.lastScan] DO FOR p: NAT IN [0..outputWindow.GetWindowParams.lastPixel] DO lineBuffer[p] _ image[s][p]; ENDLOOP; AIS.UnsafeWriteLine[outputWindow, lineBufferDesc, s]; ENDLOOP; AIS.CloseFile[ais]; AIS.CloseFile[output]; }; Expand: PROC [name: ROPE] ~ TRUSTED { colorDisplay: ImagerPixelMaps.PixelMap _ ImagerFrameBuffer.GrayScaleDisplay8[]; ais: AIS.FRef _ AIS.OpenFile[name: name]; output: AIS.FRef _ AIS.CreateFile[name: name, raster: DoubleRaster[AIS.ReadRaster[ais]]]; DoubleRaster: PROC [raster: AIS.Raster] RETURNS [AIS.Raster] ~ CHECKED { raster.scanCount _ raster.scanCount*2; raster.scanLength _ raster.scanLength*2; IF raster.bitsPerPixel # 8 THEN ERROR; RETURN [raster] }; window: AIS.WRef _ AIS.OpenWindow[ais]; outputWindow: AIS.WRef _ AIS.OpenWindow[output]; BufferRep: TYPE ~ PACKED ARRAY [0..3000) OF [0..256); nPerLine: NAT _ window.GetWindowParams.lastPixel+1-window.GetWindowParams.firstPixel; waste: NAT _ 3000-nPerLine; lineBuffer1: REF BufferRep _ NEW[BufferRep]; lineBuffer2: REF BufferRep _ NEW[BufferRep]; lineBuffer1Desc: AIS.Buffer _ [length: SIZE[BufferRep], addr: BASE[lineBuffer1^]]; lineBuffer2Desc: AIS.Buffer _ [length: SIZE[BufferRep], addr: BASE[lineBuffer2^]]; AIS.WriteComment[output, AIS.ReadComment[ais].Concat[" Doubled"]]; AIS.WritePhotometry[output, AIS.ReadPhotometry[ais], AIS.ReadHistogram[ais]]; FOR i: NAT IN [0..window.GetWindowParams.lastScan] DO AIS.UnsafeReadLine[window, lineBuffer1Desc, i]; FOR j: NAT IN [0..nPerLine) DO lineBuffer2[2*j] _ lineBuffer2[2*j+1] _ lineBuffer1[j]; ENDLOOP; AIS.UnsafeWriteLine[outputWindow, lineBuffer2Desc, 2*i]; AIS.UnsafeWriteLine[outputWindow, lineBuffer2Desc, 2*i+1]; ENDLOOP; AIS.CloseFile[ais]; AIS.CloseFile[output]; }; END. vAISTest.mesa Michael Plass, December 27, 1983 10:15 am Last Edited by: Beach, December 16, 1984 9:26:29 am PST ʘJ™ J™)J™7JšÏk œ/˜8šœ œ˜Jšœ.˜5Jšœ˜Jšœœœ˜šÏnœœœœ˜#JšœO˜OJšœ#˜#Jšœ'˜'JšœÎ˜ÎJšœœG˜ZšœœœE˜TJšœ+˜.Jšœ˜Jšœ&˜&Jš˜—Jšœ˜J˜—šžœœœœ˜%JšœO˜OJšœœœœ˜6Jšœ'˜'Jš œ œœœ œœœ˜8Jšœ œ œX˜wJšœœ>˜QšœœœE˜TJšœ+˜.šœœœ˜'Jšœœœ˜-Jš˜—Jšœ,˜/Jš˜—Jšœ˜Jšœ˜J˜—šžœœœœ˜%JšœO˜OJšœœœ˜)šœœœ+œ˜Wš ž œœ œ œœ œ˜FJšœ&˜&Jšœ(˜(Jšœœœ˜&Jšœ ˜Jšœ˜——Jšœ'˜'Jšœ0˜0Jš œ œœœ œ ˜5Jšœ œH˜UJšœœ˜Jšœ œ œ ˜,Jšœ œ œ ˜,Jšœœœœ˜RJšœœœœ˜RJšœœ*˜FJšœœœ˜Mšœœœ,˜;Jšœ.˜1Jšœ)œ*˜Yšœœœ˜ Jšœœœ˜%JšœœV˜pJš˜—Jšœ3˜6Jš˜—Jšœ˜Jšœ˜Jšœ˜J˜—šžœœœœ˜%Jšœœœ˜)šœœœ.œ˜Zš ž œœ œ œœ œ˜IJšœœ˜ Jšœœœœ˜>J˜Jšœ˜Jšœ%˜%Jšœ Ïc=˜]Jšœ ˜Jšœ˜——Jšœ'˜'Jšœ0˜0Jš œ œœœ œ ˜4Jšœ œH˜UJšœœ˜Jšœœ œ ˜'Jšœ œ œ ˜+Jšœœœœ˜PJšœœ5˜QJšœœœ˜Mšœœœ,˜;Jšœ œ ˜Jšœ5˜5Jš˜—šœœœ&˜5Jšœ+˜.šœœœ'˜6Jšœ˜Jš˜—Jš˜—šœœœ,˜;šœœœ-˜