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)