quantitativeTEM / StatSTEM

GNU General Public License v3.0
47 stars 25 forks source link

Update loadDMfile.m #30

Closed grahamsno closed 1 year ago

grahamsno commented 1 year ago

Rotate and mirror DM files such that they appear correctly

grahamsno commented 1 year ago

That is true and works well for a single image, but fails when trying to load an image series (both obs = transpose(obs) and obs = obs.').

On Thu, Nov 17, 2022 at 5:13 PM Thomas Friedrich @.***> wrote:

@.**** commented on this pull request.

I think this transformation may actually be the same as taking the transpose of the matrix. (i.e.: obs = obs'), which happens regularly when data is read and written in in different format. (Row-major vs. Column-major Format). Perhaps check if this works. That would make the code simpler, faster and would avoid the necessity of the imaging toolbox for the imrotate() function.

— Reply to this email directly, view it on GitHub https://github.com/quantitativeTEM/StatSTEM/pull/30#pullrequestreview-1184624150, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASMTR4QIZWY443FQW45YESTWIZKTFANCNFSM6AAAAAASDPZWAQ . You are receiving this because you authored the thread.Message ID: @.***>

ThFriedrich commented 1 year ago

I suppose the matrix coming from the file is 3-dimensional then? In this case we could permute the matrix. Suppose, we had a stack of images in order [nx, ny, nz] (nz being the stacking dimension), we could probably do something like: obs = permute(obs,[2,1,3]);

grahamsno commented 1 year ago

Yes, I tested it on both a single image and an image series and this works as well. obs = permute(obs, [2 1 3]);

ThFriedrich commented 1 year ago

Great. Thanks a lot for checking and working on this. :) Though both implementations produce the same result, I'd recommend updating the pull request accordingly. It may seem a bit petty, but I think there's compelling reasons to avoid functions like imrotate() when possible. Mainly, Matlab has no proper version control, not for the core and not for its toolboxes. So any new Matlab release may break the code. The chance they'll change the implementation of something as fundamental as the permute function is extremely small though. In this case we can even avoid the dependency on the image-processing toolbox.