hello, thanks for your reply, the technique you describe do appear to work if my neural network already know the shape that it has to extract, but the problem be that it has no idea what shape it has to extract, it is only given an image, so information about what does a particular shape look like is not an input.
for example, if I see an image that I have never seen before, and I do not know what is that image about, still I am able to extract patches from it, of non square/rectangular shape.
currently the only way I know is to use unfold, that also, to extract square/rectangular patch, that also, I will have to manually input the shape of the patch that I want to extract.