From ImageJ to Matlab Conversion
显示 更早的评论
HI.
Can someone translate this ImageJ piece of code to MATLAB equivalent. If not, is there an app for automated conversion between those two formats?
Thank you
for(i=1;i<=nSlices;i++){
setSlice(i);
run("Translate...", "x="+i*xTranslate+" y="+i*yTranslate+"
interpolation=None slice");
}
6 个评论
Considering that the subset of persons that know how to script ImageJ and know matlab is probably not that big, if you know what the above code is doing (particularly the setSlice) you'll get more chance of getting help.
All I can guess is that it translate (which you can do with imtranslate) some slices. It's unknown what these slices are.
Stelios Fanourakis
2018-7-12
Guillaume
2018-7-12
Translating a stack of image is trivially done in matlab with imtranslate. So, if it's all you need to do, just use that function.
Stelios Fanourakis
2018-7-12
Guillaume
2018-7-12
Oh, I didn't realised it was you. Well, as you've requested, I will not get involved in your questions.
Guillaume
2018-7-12
For others, this is a follow-up to
- griddedinterpolant-and-gridvectors-turn-image-to-binary
- does-anyone-know-why-the-images-appear-that-way
- can-imtranslate-and-squeeze-be-combined-to-one-code-line
and many more.
回答(1 个)
Sean de Wolski
2018-7-12
编辑:Sean de Wolski
2018-7-12
Looks like imtranslate should work. My interpretation of that is: loop over slices, translate each slice by some amount (that value may vary by slice - I don't know). You may not be able to do it all in one shot but it should certainly work. Something along these lines, not tested.
VT = zeros(size(V),'like',V)
for ii = 1:size(V,3)
VT(:,:,ii) = imtranslate(V(:,:,ii), [something_row(ii), something_col(ii)])
end
Can you describe what you're trying to do, i.e. what is the end goal?
15 个评论
Stelios Fanourakis
2018-7-12
Stelios Fanourakis
2018-7-12
Sean de Wolski
2018-7-12
[row(ii), col(ii),0,0]
is four elements. It should be two to translate in row/col or three to translate in row/col/slice. It won't translate into 4d.
Stelios Fanourakis
2018-7-12
Stelios Fanourakis
2018-7-12
Sean de Wolski
2018-7-12
Squeeze a 4d grayscale image to make it 3d.
Apparently to translate into 3d, you need a 3d matrix. That might mean it makes more sense to do the 3d part of the translation all at once. I.e. loop over translating in 2d if slices translate different amounts, then do the 3d piece all at once.
I don't really understand what your goal is but certainly some combination of these steps is what you want.
Stelios Fanourakis
2018-7-12
Rik
2018-7-12
Nobody is born knowing how to do stuff in Matlab. A great method of learning how Matlab works is to actually read the documentation of function you're guessing might be useful. The documentation is quite good, it's one of the big advantages over Octave.
Permute changes the order of dimensions of an array. You could certainly use it here, but you don't necessarily need it.
Stelios Fanourakis
2018-7-13
编辑:Stelios Fanourakis
2018-7-13
Stelios Fanourakis
2018-7-13
Stelios Fanourakis
2018-7-13
Sean de Wolski
2018-7-13
Different y/x but no translation in z? If so, squeeze the stack of images to get 3d, run the loop over each one like I did above, and pass just the x/y parameters into imtranslate. Basically exactly what I have in the answer.
Sean de Wolski
2018-7-13
permute is the equivalent of imagej reslice I believe. I haven't looked at ImageJ since 2009 when I rewrote everything we were doing there in MATLAB. There are no plugins to my knowledge and with my knowledge of ImageJ at the time getting as far away from it as possible was the best practice.
Stelios Fanourakis
2018-7-13
Stelios Fanourakis
2018-7-15
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!