<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Thank you for the reply, Rob.<div class=""><br class=""></div><div class="">That was helpful. Can you verify my logic? If I want a CFITSIO style cutout, like so:</div><div class=""><br class=""></div><div class="">[1][12:20,12:20]</div><div class=""><br class=""></div><div class="">And I have 6 tiles of 10x10 (100 pixels) like so:</div><div class=""><br class=""></div><div class="">+——————+——————+——————+——————+<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">——————+</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">——————+</span></div><div class="">| | | | | | |</div><div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">| | | | | | |</span></div><div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">| | | | | | |</span></div><div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">| | |---------------------------------------------------------------------------------| |</span></div><div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">| | | | | | |</span></div><div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">| | | | | | |</span></div><div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">+——————+——————+——————+——————+</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">——————+</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">——————+</span></div><div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class=""></span></div><div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">I’m able to get the correct size sub image by doing some pseudo-code like:</span></font></div><div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""><br class=""></span></font></div><div class=""><font color="#000000" class="">integer tileSize = 100</font></div><div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">integer offset = 12 * 12 // 144</span></font></div><div class=""><font color="#000000" class="">Integer rowStart = offset / tileSize // 1</font></div><div class=""><font color="#000000" class="">Integer rowOffset = offset % tileSize<span class="Apple-tab-span" style="white-space:pre"> </span>// 44 - Offset into the tile</font></div><div class=""><font color="#000000" class="">Integer length = 20 * 20 // 400</font></div><div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">while(keepReading) {</span></font></div><div class=""><font color="#000000" class=""> row = image.row(offset)</font></div><div class=""><font color="#000000" class=""> compressedData = row[0]</font></div><div class=""><font color="#000000" class=""> d<span style="caret-color: rgb(0, 0, 0);" class="">ata = decompressRice(compressedData)</span></font></div><div class=""><font color="#000000" class=""> for (I = rowOffset; I < data.length && I < length; I++) {</font></div><div class=""><font color="#000000" class=""> readData()</font></div><div class=""><font color="#000000" class=""> }</font></div><div class=""><font color="#000000" class=""> o<span style="caret-color: rgb(0, 0, 0);" class="">ffset = offset + 1</span></font></div><div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">}</span></font></div><div class=""><font color="#000000" class=""><br class=""></font></div><div class=""><font color="#000000" class="">Which will read 400 pixels by reading row by row for the entire length, </font><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">starting at pixel 144,</span><span style="color: rgb(0, 0, 0);" class=""> like in my terrible ASCII image above. </span></div><div class=""><font color="#000000" class=""><br class=""></font></div><div class=""><font color="#000000" class="">The problem is the that my pixel values are incorrect. Could there be a problem with the Rice decompression? Or are my offsets incorrect, possibly?</font></div><div class=""><font color="#000000" class=""><br class=""></font></div><div class=""><font color="#000000" class="">Many thanks for any input,</font></div><div class=""><font color="#000000" class="">Dustin</font></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 18, 2022, at 8:12 PM, Seaman, Robert Lewis - (rseaman) <<a href="mailto:rseaman@arizona.edu" class="">rseaman@arizona.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Hi Dustin,<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I can’t speak to nom-tam-fits support for what you want to do, but FITS tile compression is designed for this, eg: “Dividing the image into tiles before compression enables faster access to small sections of the image because only those tiles covering the area of interest need be uncompressed.” (<a href="https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/docs/fpackguide.pdf" style="color: blue; text-decoration: underline;" class="">https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/docs/fpackguide.pdf</a>)<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">See the discussion under ZTILEn in the FITS convention (<a href="https://fits.gsfc.nasa.gov/registry/tilecompression/tilecompression2.3.pdf" style="color: blue; text-decoration: underline;" class="">https://fits.gsfc.nasa.gov/registry/tilecompression/tilecompression2.3.pdf</a>) for the header keywords to sort it out. Either you or the library will then need to index from the table into the heap. By default, the tiles are row-by-row which makes the arithmetic easier. If there are constraints on the sub-images of interest such as location or size, the tiles can be tuned to optimize access.<o:p class=""></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Rob<o:p class=""></o:p></div><div style="border-style: none none solid; border-bottom-width: 1pt; border-bottom-color: windowtext; padding: 0in 0in 1pt;" class=""><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif; border: none; padding: 0in;" class=""><o:p class=""> </o:p></div></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div class=""><div style="margin: 0in 0in 0in 0.5in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">On 10/18/22, 7:29 PM, "fitsbits" wrote:<o:p class=""></o:p></div></div><div style="margin: 0in 0in 0in 0.5in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><o:p class=""> </o:p></div><div class=""><div style="margin: 0in 0in 0in 0.5in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I’m using the nom-tam-fits Java library to extract a sub image from a compressed image binary table. Typically, the compressed image is decompressed and one can perform a normal extraction, but my service exists on the Cloud and needs to be able to cutout in a streaming manner. Is there a way to look at the Header and know what row in the table (or which tile) that overlaps some range of pixels? Alternatively, would I need to iterate the tiles to see if any of them overlap?<br class=""><br class="">Many thanks,<br class="">Dustin<br class="">CADC<br class=""><br class="">_______________________________________________<br class="">fitsbits mailing list<br class=""><a href="mailto:fitsbits@listmgr.nrao.edu" style="color: blue; text-decoration: underline;" class="">fitsbits@listmgr.nrao.edu</a><br class=""><a href="https://listmgr.nrao.edu/mailman/listinfo/fitsbits" style="color: blue; text-decoration: underline;" class="">https://listmgr.nrao.edu/mailman/listinfo/fitsbits</a></div></div></div></div></blockquote></div><br class=""></div></body></html>