Question

So I have a huge 3D array that is a scan of some tissue. I need to be able to replace all non zero entries in this array with 1, and keep all zeros the same. How can I go about this?

Then, once I've done this I need to calculate the jaccard similarity coefficient (JSC) which I can use matlabs built in functions union() and intersect() , I just need to find a way of finding the number of voxels in the tissue (i.e. if my array is x, I need to find |x|)

Any help is appreciated!

Was it helpful?

Solution

The first part is simple using logical indexing (example):

I = ~~I;

Although it's probably more realistic to set everything above a threshold to 1 and everything below to 0:

th = 0.001; %//for example
I = I >= th;

So as for the JSC based on wikipedia I'm assuming you're comparing two equal sized binary images? Lets say I and x:

M11 = nnz(I & x);
M10 = nnz(I & ~x);
M01 = nnz(~I & x);
M00 = nnz(~I & ~x);

JSC = M11/(M10 + M01 + M11)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top