Extract patches (x,y) error

username: randino
cooked: <p>how to know left and left and top and bottom so that I can know the patch  as illustrated in this figure. I just know the size of the original image</p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/3X/a/1/a1b3d37483b193da2bd1cc144cc3c2a1e3d240bf.png" alt="image" data-base62-sha1="n4u9bxqYbQzBXZCltIqoOPgO4JV" width="399" height="285"></p>

username: ptrblck
cooked: <p>The illustrated patch positions seem to be a bit random besides the bottom right corner touching the black/while border.<br>
If that’s your use case, you could select this point by checking where the black pixels start from left to right and top to bottom and select this point as the coordinate. The other coordinates seem to be somewhere in the while area so you could probably pick them as you want as long as they are inside the image.</p>

username: randino
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a>  I want to retrieve the axes (x, y) of each central pixel. when I get the patches, I get the central pixel and its axes. who plz</p>
<pre><code class="lang-auto">patches = image.extract_patches_2d(mat_gt['difftaille200'], ((5,5)))
labels_p=patches.reshape(patches.shape[0], patches.shape[1]*patches.shape[2])
labels=labels_p[:,12]
</code></pre>
<p>because I want to display the final image after the prediction.</p>
<p>the size of original image=100*100, I toolk 60%train , and 40%test<br>
help me</p>

username: ptrblck
cooked: <p>The <code>patches</code> would have the shape <code>[n_patches, patch_height, patch_width]</code> or <code>[n_patches, patch_height, patch_width, n_channels]</code> so you could access the center pixels by indexing <code>dim1</code> with <code>patch_height//2</code> and <code>dim2</code> with <code>patch_width//2</code>.</p>

username: randino
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a>  how I transform matrix to image</p>
<pre><code class="lang-auto">for i in range (37) :
  for j in range (95) :
        k=k+1;
        t[i,j]= result[k];
       plt.imshow(t)

</code></pre>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/c/cc572658adb076374d50d53b9f50760cdaa32789.png" data-download-href="https://discuss.pytorch.org/uploads/default/cc572658adb076374d50d53b9f50760cdaa32789" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/c/c/cc572658adb076374d50d53b9f50760cdaa32789.png" alt="image" data-base62-sha1="t9G7xbDWe57f0EYh7FeZDF8wcE9" width="690" height="362" data-dominant-color="FAFAFB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">770×405 14.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: ptrblck
cooked: <p>Assuming the matrix has the expected shape it would work directly:</p>
<pre><code class="lang-python">a = np.random.randn(10, 10)
plt.imshow(a)
</code></pre>
<p>However, as your error message points out you are using an <code>object</code> dtype, so you are most likely mixing different arrays into one. Search for this error message and you should be able to find more explanations of this issue.</p>