How to Crop Stacks in ImageJ without first Duplicating - macros

I am using imageJ for automated microscopy of live cells.
The microscope centers the stage on a desired cell, takes a Z-stack, and passes this stack to imageJ.
I want to then use Analyze Particles to output the area of the cell in each Z-slice. (this works well)
To do this I use a macro which performs the following:
A region is selected.
The selected region stack is duplicated
the stack is autothresholded.
Analyze particles is run for the stack (with objects on border excluded)
the maximal area result is found
the corresponding z-slice is printed in a file for further work.
This all works well except the duplicate step is far too slow for the pipeline. I need to avoid the duplication step somehow.
Is there any way to crop the stack without first duplicating? (currently this loses information from all but one slice)
Or, can I apply the threshold and analyze particles only to the selected region?

Cropping a stack can be done in a macro using run("Crop"); following an appropriate selection.

Related

determining the properties of pores

I have several series of segmented images and I need to calculate the properties (area, perimeter, radius of the largest circle fitting in area) of the black areas (pores). I could not find the value with the software imagej as it seems that it has some problems in distinguishing the holes (569 area was found) and I tried to find the values by regionprops in matlab. however, it seems that it has the same problem (570 area was found). So, can anybody please help me find the solution to this question?
here is the areas found by imagej.
The black regions bleed into one another and ImageJ cannot distinguish them. If you use Process > Binary > Watershed, this will segregate the regions into (most likely) separate objects. Be aware that you may need to invert the image before doing this. Then you can use Analyze > Analyze Particles... to find the objects. The measurements that ImageJ produces can be controlled using Set Measurements and in the dialog for Analyze Particles. It will do area and perimeter for each object, but not (AFAIK) the radius of the largest circle.

Resizing image generated by PaintCode app

I have imported a vector image to PaintCode app and then export its Swift to code. I want to use this vector image in a small View (30x30) but since I want it to work on different devices, I need it to be size-independent.
The original size of the vector image is 512x512. When I add its class to a UIView, only a very small part of the vector image can be seen:
I need to somehow resize the image that can be fit in any size of a frame. I read somewhere, that I have to draw a frame in PaintCode app around the image, I did it but nothing changed.
Start by selecting the "Frame" option from the toolbar
Apply the frame to you canvas...
nb: If you mess up the frame DELETE IT and start again, modifying the frame can change the underlying vector, which is annoying
Apply the desired resize options. This can be confusing the first time.
I group all the elements into a single group. Select the group and on the "box" next to the coordinates of the group, change all the lines to "wiggly" lines. This allows paint code the greatest amount of flexibility when resizing the image...
Finally, change the export options. I tend to use both "Drawing" and "Image" as it provides me the greatest amount of flexibility during development
You should also look at Resizing Constraints, Resizing Drawing Methods and PaintCode Power User: Frames for more details

Export to vector graphics fails with large number of data-points

I want to export some MATLAB-plots as vector-graphics for presentations. In the most cases, using print-command, for example:
set(0,'defaultAxesTickLabelInterpreter','Latex')
set(0,'defaultTextInterpreter','Latex')
t=linspace(0,6,6000);
s=sin(t);
figure
for spl=1:16
subplot(4,4,spl);
plot(t,s,'k')
end
print('Sinetest','-dpdf');
but as soon as the number of data-points (or the expected file size) turns too big, for example use t=linspace(0,6,7000); the method fails: instead of a scalable vector graphic, an ugly pixel-monster is saved in the .pdf-file. I've tried to use other file-formats, for exampl .emf, .eps, .svg (svg is what I need actually) instead of .pdf, but it's always the same problem. Reducing the number of data points works in this example, but not in general for me.
Is there any option or work around?
The solution is to specify that the painter renderer should be used:
print('Sinetest','-dpdf', '-painters');
If you save to a vector graphics file and if the figure RendererMode
property is set to 'auto', then print automatically attempts to use
the Painters renderer. If you want to ensure that your output format
is a true vector graphics file, then specify the Painters renderer.
Note that this may result in long rendering times as mentioned in the docs:
Sometimes, saving a file with the '-painters' option can cause longer
rendering times [...]

Dynamically extendable ladder shape

My question is two parts, and answers to either would be helpful.
I want to make a Master shape that can be expanded on one axis only. When you expand it the image inside repeats itself. I still want to be able to resize the image proportionally. See the picture for example.
Discrete extendable ladder
The second part of my question is how to restrict this expansion to discrete segments, meaning that the expanded image snaps to the next segment when it gets close enough, but nothing in between. I think I can do this with the BOUND() function, just not sure how.

Matlab imshow update image at old position and magnification

I currently use Matlab's imshow to output an image at every iteration of a diffusion filter process, i.e. multiple times per second.
Sometimes during filtering I want a closer look at specific image parts.
However, when using the ('Parent', handle) name-value pair for imshow the magnification and position gets reset.
Is there a way to update the underlying image but having the magnification and position intact?
You can update the cdata in the current axis to your new data matrix which will keep all other settings the same. If this is in a loop, you probably need to call drawnow. E.g:
x=randn(100);
figure;imagesc(x);
Now zoom / pan / do whatever manipulations you want.
f=gca;
x=randn(100);
f.Children.CData = x;
This method of updating of child data is recommended by Matlab as more efficient than destroying the axis child Image and recreating each frame (can't remember the source, it was in one of the help files).
Edit: Just remembered that this syntax won't work on older versions of matlab (pre 2015 or so). In that case, use get/set syntax:
set(get(gca,'Children'),'CData',x);