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
The illustrated patch positions seem to be a bit random besides the bottom right corner touching the black/while border.
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.
@ptrblck 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
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]
because I want to display the final image after the prediction.
the size of original image=100*100, I toolk 60%train , and 40%test
help me
The patches
would have the shape [n_patches, patch_height, patch_width]
or [n_patches, patch_height, patch_width, n_channels]
so you could access the center pixels by indexing dim1
with patch_height//2
and dim2
with patch_width//2
.
@ptrblck how I transform matrix to image
for i in range (37) :
for j in range (95) :
k=k+1;
t[i,j]= result[k];
plt.imshow(t)
Assuming the matrix has the expected shape it would work directly:
a = np.random.randn(10, 10)
plt.imshow(a)
However, as your error message points out you are using an object
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.