A few things:
You might not want to merge the channels in the image, because it's generally easier to work with composite images where each channel is separate. If you have each TIFF pair in a folder, you can open the pair as an image stack by dragging the folder onto ImageJ. Some info on color images here - http://rsbweb.nih.gov/ij/docs/guide/146-9.html#toc-Section-9
JPEG is a lossy file format, so you lose image quality every time you save to JPEG. You're better off using TIFF.
The simplest way to quantify the green area is to take the single-channel green image and threshold it until only the sufficiently green bits are selected, fill in the holes, then use the particle analysis tool to calculate the area.
Here's some screenshots of the steps - http://postimg.org/gallery/77u22l2g/
1) For the green image, use the threshold tool to select the sufficiently green area.
2) Press 'Apply' to get a binary image
3) Use the 'Fill Holes' tool to automatically fill in the holes
4) Open up the 'Analyze Particles' tool and select the appropriate options. I've set the minimum size to 500 so that only the largest area is calculated. You could also skip the fill holes step and do that here. By selected "Include holes"
5) Results. It has an area of 144349 pixels. If you calibrate the scale you will get a more useful unit of measurement.
It's possible to automate this using macros, but depending on the consistency of staining and imaging, you might need different thresholds for each image. Ask around your lab to see if anyone there can help you write/record a macro. :)
First Rule: the Macro Recorder is your friend. Also: go and read the basics and know where to find the macro functions.
Try this on your sample image:
original = getImageID(); run("Properties...", "channels=1 slices=1 frames=1 unit=pixel pixel_width=1.0000 pixel_height=1.0000 voxel_depth=1.0000 frame=[0 sec] origin=0,0"); run("8-bit"); setAutoThreshold("Otsu"); run("Set Measurements...", "area mean standard modal min center perimeter bounding fit shape feret's integrated median redirect=None decimal=3"); run("Analyze Particles...", "size=30-Infinity circularity=0.00-1.00 show=Masks display clear include record"); selectImage(original); resetThreshold(); xm = getResult("XM",0); // centre of mass ym = getResult("YM",0); // centre of mass angle = getResult("FeretAngle",0); // angle => slope length = getResult("Feret",0); if(angle>90){angle = 180 - angle; sign = -1;} else {sign = 1;} slope = sign*atan(angle*PI/180); print("Centre of mass: " + xm + ", " + ym); print("Slope: " + slope); setPixel(xm,ym,255); distance = length/6; x = distance / sqrt(1 + slope*slope); xa = xm + x; xb = xm - x; ya = ym - slope*x; yb = ym + slope*x; setPixel(xa,ya,0); print(xa + ", " + ya); setPixel(xb,yb,0); print(xb + ", " + yb);
I'll let you figure out how it works.
And pay it forward ;)
Yes, modifying the results table output is a rather trivial task. There are two ways to add extra columns. The easy way for most of them is editing the 2nd of these two lines (the first is just a reminder):
// Set Measurements... ensure "Stack Position" and "Centre" are included run("Set Measurements...", "area mean min center stack redirect=None decimal=4");
That line is just the set of commands that I selected to for the particle analysis. It's easy to modify: Go to Plugins > Macro > Record..., then do Analyze > Set Measurements... and check off all of the ones that you want. Once you press "OK", the code for that will be in the Macro Recorder window. Copy, paste, voila!
The second way is easy if you're just doing simple math or something like that: to run a small loop.
for(i=0; i<nResults; i++){ a = getResult("Item",i); setResult("Item Squared",i,a*a); } updateResults();
You can also do some slightly more complicated tricks, such as using the ROI manager to select individual particles, then to record whatever statistics you want about it using the getStatistics(area, mean, min, max, std, histogram) macro function. Of course, "Set Measurements" does most of that, however with the "histogram" output, you can do other custom analyses. There's a huge list of different functions that can be employed (and imagined), so it's worth exploring.
Time to get the undergrads to learn programming! ;-) ImageJ is actually quite a good introduction to programming, as it's easy to get both text and visual feedback on what each command does. I usually try to teach it and the basics of Python (how I learned!) to my undergrads.
I'm on mobile right now so I can't really help, but you can definitely do this. There is a measurement tool that identifies and counts shapes, and you can set the size limit, and "circularity" with '1' being a perfect circle; then the software will identify all the objects that satisfy those parameters. Look here:
http://rsbweb.nih.gov/ij/docs/guide/146-30.html
And if that doesn't help, go to google - I know I've see video tutorials that cover this.
So sorry I can't be more helpful right now. Good luck!
> For the assignment as part of my report, I am required to provide a "computer algorithm" for how I edited the images...Am I right in assuming that involves some kind of coding?
> My lecturer has stated we can also just write a "What I did" step by step recount, but I feel in order to get me higher marks I should try and include a computer algorithm.
As /u/DaftPotato mentioned, the macro recording functionality is very useful. Just turn it on before you start editing the image(s) by going to Plugins > Macros > Record... on the menu. You can then copy the output to use as a macro; it will repeat everything that you did when it runs.
ImageJ has loads of built-in macro functions and the macro basics is a good place to get started. Also, you'll find that most of the macro functions in the prior link includes an example: looking at those is a good way to see how they work. You can just copy & paste the code into a new macro window (Plugins > New > Macro) and then run it (CTRL + R).
Also, TIFF images are entirely compatible with ImageJ.
Not a problem. Follow the examples that are provided with the built-in functions or come back & ask more questions if those aren't 100% clear.
On the macro functions list there is a collection of Plot Functions, all of which start with Plot.
I'm presuming that your "standardized selction" is a profile plot (??) - if so, you can get the data from each individual plot using
Plot.getValues(xpoints, ypoints);
Then re-plotting the sets sets of data using the aforementioned Plot Functions.
This explanation of FFT filtering is for imagemagick, but should give you some idea of what /u/DaftPotato is talking about.
edit: specifically, the sections on noise removal and the spectrum of a grid.
Computer vision is a different, yet related problem to image processing -- I conjecture your project is more likely inside computer vision.
Have you considered OpenCV?
If you must use ImageJ -- would you be allowed to write a plugin instead? I find that easier than including the jar, personally.
If including the jar is needed because it's to run in command line in a nice long posix pipe, then I think I have a general idea of what you're getting at.
Good luck!
> Has anyone found a better way to convert a 121 image stack to a series of 121 CSV files?
I would do it outside of imageJ if you have a little programming ability. Doing a quick search led me to:
https://stackoverflow.com/questions/37722139/load-a-tiff-stack-in-a-numpy-array-with-python
and if you combine that with:
https://docs.python.org/2/library/csv.html
you should be able to do what you need with a dozen or so lines of code. I'm sure it could be done in other languages as well if you are more familiar with something else
That's strange. I've never had the problem before, so I don't know what could be causing it. Is it a particularly large file?
As an if-all-else-fails solution, GIMP also can export GIFs, with user-determined frame rates.
Yes, it can be written. I haven't used DistributionJ myself -- What's the title of the histogram window that gets opened? I can write a quick function for you, otherwise see these two links:
Writing details is fairly simple:
open("http://i.imgur.com/0FvM1py.jpg"); setForegroundColor(200,200,0); setFont("Monospaced",80,"bold"); setJustification("left"); x = 2350; y= 780; drawString("Is this a \nchannel?",x,y); setForegroundColor(220,90,75); x = 1400; y = 1020; setFont("Arial",30,"bold"); drawString("What about this one?",x,y);
You can write whatever string you want at whatever location you want (x,y). There's also a good demo macro on the ImageJ website. For the other stuff, I'd need to see what you want to do... but there are links for guides to macro stuff in the side bar.
When each image is opened, it would probably help to use the "ImageID" for each image:
x = getImageID();
How do you have your images sorted / organized?
One other useful item in the ImageJ macro toolbox is the histogram function:
getHistogram(values, counts, nBins[, histMin, histMax])
So a simple macro along these lines can automatically set the threshold to a set percentage of the histogram:
percentage = 0.75; target = percentage*getWidth()*getHeight(); nBins = 256; getHistogram(values,counts,nBins); sum = 0; threshold = -1; for(i=0; i<nBins; i++){ sum += counts[i]; if( (sum >= target) & (threshold < 0) ){ threshold = i; } } setThreshold(0, threshold);
Uh... your first question doesn't quite make sense. To create a mask, you need to threshold the image:
Image> Adjust > Threshold...
Beyond that, you need to imagine a specific set of instructions which would let you find the features that you're looking for, and then imagine how you would measure them... break it all down into the smallest possible step. Then look through the list of functions to see if any would do what you need. If not, then you make a function that does (this can be done within the macro).
This may also be a good place to look for ideas: http://imagej.1557.x6.nabble.com/Dendritic-spine-td3685212.html
I take it that this is what you're referring to: Free Selection (Lasso)?
Kind of. There's the Polygon Selection Tool & the Freehand Selection Tool, which can be used to make a series of line segments to enclose an object.
I've never heard of this before or noticed an issue with it. Could you convert your greyscale images to RGB using Image > Type > RGB Color first? I use Inkscape for my figure layout and I've never noticed an issue. How are you importing figures from Inkscape into Adobe Illustrator? I usually save mine as PNG files before embedding them in Inkscape.