Perform local filtering on 3D image
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I would like to perform a Gaussian smoothing on a 3D image. I know I can do this using imfilter, but I only need to perform the filter on certain voxels. Therefore, I have a (sparse) 3D binary mask containing the voxels that needs to be filtered. I can do the filtering on the entire image and then only keep the masked voxels from the filtered images. However, this is too time consuming and not very efficient because for most of the voxels, we do not need the filtered result. Does anybody know an efficient way of doing this?
0 comentarios
Respuestas (1)
Kushagr Gupta
el 16 de Mzo. de 2017
Editada: Kushagr Gupta
el 16 de Mzo. de 2017
To perform localized Gaussian filtering either 2D or 3D in MATLAB, you would need to provide the filtering function with that specific portion of image that needs to be filtered. This could be done by using matrix indexing to extract the regions that need to be filtered.
Note: As filtering images requires spatial contiguity, filtering would make sense if the 3D binary mask has voxels that are in each others neighborhoods. In other words filtering individual voxels would not yield any useful result.
Thus, taking an example where filtering is being performed on a 100x100x3 region in an image, it could look like:
originalRGB = imread('peppers.png');
imshow(originalRGB)
sigma = 2;
% perform gaussian filtering on entire image
volSmooth = imgaussfilt3(originalRGB, sigma);
figure
imshow(volSmooth)
% local filtering on a certain region in an image.
volSmooth2 = imgaussfilt3(originalRGB(100:200,100:200,:), sigma);
finalVol = originalRGB;
finalVol(100:200,100:200,:) = volSmooth2;
figure
imshow(finalVol)
This was an easy illustration to show how indexing can be made use of for rectangular regions. Moreover, I do not believe sparse spatial filtering is possible in MATLAB as of now (wherein you could just give a sparse matrix and have the filter operate on that).
Hence, a suggestion would be to get the regions of interest in bounding boxes and pass those boxes as inputs to the filtering function.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!