Filter löschen
Filter löschen

Delete certain pixels in 3D matrix

1 Ansicht (letzte 30 Tage)
Oded Scharf
Oded Scharf am 12 Aug. 2018
Beantwortet: Oded Scharf am 15 Jul. 2019
Hey, I need to clean a video by deleting specific pixels in each frame using 'regionprops'.
When I use 'PixelList' in the indexing it deletes whole squares and not the specific pixels:
for frame=1:size(bin_angiogram,3)
region_angiogram(:,:,frame)=bwlabel(bin_angiogram(:,:,frame));
stats=regionprops(region_angiogram(:,:,frame),'Area','PixelIdxList');
for region=1:size(stats,1)
if stats(region).Area<3000
region_angiogram(stats(region).PixelList(:,2),stats(region).PixelList(:,1),frame) =0;
end
end
end
and if I try to do it using 'PixelIdxList' it is extremely slow:
for frame=1:size(bin_angiogram,3)
region_angiogram(:,:,frame)=bwlabel(bin_angiogram(:,:,frame));
stats=regionprops(region_angiogram(:,:,frame),'Area','PixelList');
for region=1:size(stats,1)
if stats(region).Area<500
L = region_angiogram(:,:,frame);
L(stats(region).PixelIdxList) = 0;
region_angiogram(stats(region).PixelList,frame) =L;
end
end
end
bin_angiogram is atached.
Do you have any Idea how can I do it?
Tanks!

Akzeptierte Antwort

Oded Scharf
Oded Scharf am 15 Jul. 2019
I found that using PixelIdxList solves the problem

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by