Asked by Sara Salimi
on 8 Dec 2018 at 17:40

Hi,

I have 3D patients volumes saved in a matlab variable.

I need to extract random shift intensity difference (RSID) feature, this feature compares the intensity of the current voxel x and another

voxel x + u with random offset u, ` f(x, u) = I(x + u) − I(x)`, where u is a random offset vector.

My question is

- How many neighbors of a specific voxel needs to be considered to calculate RSID?
- How to find them with matlab code?

Your help is appreciated

Answer by Image Analyst
on 9 Dec 2018 at 0:34

I think you'd have to scan your 3-D value one voxel at a time.

If you just want the intensity difference over all the neighbors, you can simply use convn with a kernel of all -1 excel the center being 26

kernel = -1 * ones(3,3,3);

kernel(2,2,2) = 26;

kernel = kernel / 26; % So output is in same intensity range as input.

output = convn(inputImage, kernel, 'same');

Why do you want the difference at just one randomly located pixel instead of the average over ALL neighbors?

Sara Salimi
on 9 Dec 2018 at 10:05

Hi again Sir,

I apologize because I missed out the last line of your question "Why do you want the difference at just one randomly locatlcued pixel instead of the average over ALL neighbors?"

I have calculated 138 different features, I saw in one paper that authors in this paper , mentioning about semantic feature (random shift intensity difference) and semantic context feature ( random shift probability difference (RSPD), which is the probability maps from a previous stage of voxel classification ). Which I do not understand how they are calculating for each voxel with 26 neighbors.

Image Analyst
on 9 Dec 2018 at 16:51

So let's see your for loop. Did it look something like this:

for slice = 1 : slices

for col = 1 : columns

for row = 1 : rows

ur = 2*randi([0, 1], 1, 1) - 1;

uc = 2*randi([0, 1], 1, 1) - 1;

us = 2*randi([0, 1], 1, 1) - 1;

randomPixel = double(image3d(row+ur, col+uc, slice+us));

thisPixel = double(image3d(row, col, slice))

diffmage(row, col, slice) = thisPixel - randomPixel;

end

end

end

If not, what did it look like?

Sara Salimi
on 11 Dec 2018 at 8:32

Could I ask is image3d the input 3D array of image, and diffimage is the output? Once I am running the last code, I am getting an error:

Subscript indices must either be real positive integers or logicals.

Error in (line 10)

randomPixel = double(inputDataVol(row+ur, col+uc, slice+us));

The intensity range for the original image has been normalized between [0,1].

Once I am running the first code, After applying the following code,

kernel = -1 * ones(3,3,3);

kernel(2,2,2) = 26;

kernel = kernel / 26; % So output is in same intensity range as input.

output = convn(inputImage, kernel, 'same');

I get an image like for RSID that I have show for a specific slide and the ranges of values is between [-0.3517:0.6728]

and for RSPD I get the following image for a specific probability map of structure, the values ranging [-0.6063: 0.6893]

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.