<div dir="ltr">Had a quick question about cropping out regions using the python interface-- I'm trying to just crap a couple of tiles and just wanted to make sure I am interpreting the coordinate frames properly...<div>
<br></div><div>So I have a slide I scanned at 40X... and I want to tile it at 20X. So I want something downsampled by a factor of two... </div><div><br><div><div><pre style>img.level_downsamples = (1.0, 4.0, 16.00027570995313, 32.00355329607886)</pre>
</div></div><div><br></div><div> mynewimage = img.read_region( [4096,4096],0,[4096,4096])<br></div><div><div><br></div><div><div><div>"location: (x, y) tuple giving the top left pixel in the level 0</div><div> reference frame.</div>
<div>level: the level number.</div><div>size: (width, height) tuple giving the region size.</div><div><br></div><div>Unlike in the C interface, the image data returned by this</div><div>function is not premultiplied."</div>
</div></div><div><pre style><br></pre><pre style>So I just wanted to double check--- in my case I want to "tile" at 20X... but while the software can pull out that information... I am not using "those" numbers to pick my region.. I am using 0,1,2,3...</pre>
<pre style><br></pre><pre style>In this case.. since the regions are 1,4,16, and 32... that would correspond to 40X, 10X, 2.5X and 1.25X....</pre><pre style>So in my case--- if I did read_region I would grab layer 0.... and then say I get a 4K box with the upper left corner at 4096,4096.... I'd then have to decimate that image by a power of two to make it a "20X" tile...</pre>
<pre style>Or is there a function that will do this for me automatically..</pre><pre style><br></pre><pre style><br></pre><pre style><br></pre><pre style>Also... I wanted to clarify exactly what "<span style="font-family:arial;white-space:normal">tuple giving the top left pixel in the level 0</span><span style="font-family:arial;white-space:normal"> reference frame." Means..</span></pre>
<pre style><span style="font-family:arial;white-space:normal"><br></span></pre><pre style><span style="font-family:arial;white-space:normal"><br></span></pre><pre style><span style="font-family:arial;white-space:normal">So if I specified layer 0 for read region... say I specify 10,000, 1000 as the upper X corner.... and then 4K by 4K as the bounding box..</span></pre>
<pre style><span style="font-family:arial;white-space:normal"><br></span></pre><pre style><span style="font-family:arial;white-space:normal">It would return a PIL object that's 4Kx4K.... and would represent the cropped region from 10,000,10,000 --> 14096,14096</span></pre>
<pre style><span style="font-family:arial;white-space:normal"><br></span></pre><pre style><span style="font-family:arial;white-space:normal">In the second example...if I specified the upper coord of 10Kx10K... but used region 1 as the level to grab... I'd still get a 4Kx4K output but instead would be a lower resolution image... and go from 10,000,10000 --> 26384/26384 in "ref frame 0 coordinate) but in "ref frame 1" coordinates would be from 1024,1024 -> (5120,5120) </span></pre>
<pre style><span style="font-family:arial;white-space:normal">Thanks!</span><br></pre><pre style><span style="font-family:arial;white-space:normal"><br></span></pre><pre style><span style="font-family:arial;white-space:normal">Also is there a function that would "grab" the 20X tiles... I may have missed it in the API documentation....</span></pre>
<pre style><span style="font-family:arial;white-space:normal"><br></span></pre><pre style><span style="font-family:arial;white-space:normal"><br></span></pre><pre style><span style="font-family:arial;white-space:normal"><br>
</span></pre><pre style><div><br></div></pre><pre style><br></pre><pre style><br></pre><pre style><br></pre><pre style><br></pre><pre style><br></pre></div><div><br></div><div><div><br></div><div>-- <br></div></div>David A Gutman, M.D. Ph.D.<br>
Assistant Professor of Biomedical Informatics<br>Senior Research Scientist, Center for Comprehensive Informatics<br>Emory University School of Medicine
</div></div></div>