Select specific area of a DICOM file

조회 수: 4 (최근 30일)
Alfredo Scigliani
Alfredo Scigliani 2022년 12월 14일
댓글: Rik 2022년 12월 15일
I am trying to select the area between the two circles, everything inside the inner circle and outside the outer is not of interest. This is how I am trying to "activate" and "deactivate" the pixels I want. By doing it twice, I am able to select part of the left and part of the right side, and then just add them up. I would like to finish with the whole area between the circle with the pixels "on". Probably this is not even the way that I should be doing it but if anybody has a recommendation I would be happy to hear! (cant upload dicom file so I will compress in zip)
also, I will take the absolute value of the selected area so no worries about it changing color from the first one to the last one.
clear; clc; clf; close all;
I(:, :, 1) = dicomread('MRIm1.dcm');
P = I(:, :, 1);
figure
subplot(2,2,1), imshow(P, [])
%%
Pb = imbinarize(P, graythresh(P));
se = strel('line', 4, 4);
Pb = imerode(Pb, se);
props = regionprops(Pb, 'Area', 'PixelIdxList');
[m, index] = max([props.Area]);
Pbm = zeros(size(P,1), size(P,2));
Pbm(props(index).PixelIdxList) = 1;
P(~Pbm) = 0;
%same thing again but with absolute value so that it inverts and takes right side
A = I(:, :, 1);
A = abs(A);
Ab = imbinarize(A, graythresh(A));
% Ab = bwareaopen(Ab, 250);
% Ab = imfill(Ab, 'holes');
se = strel('line', 4, 4);
Ab = imerode(Ab, se);
props1 = regionprops(Ab, 'Area', 'PixelIdxList');
[n, index1] = max([props1.Area]);
Abm = zeros(size(A,1), size(A,2));
Abm(props1(index1).PixelIdxList) = 1;
A(~Abm) = 0;
C = P + A; %just adds them
subplot(2,2,2), imshow(P, [])
subplot(2,2,3), imshow(A, [])
subplot(2,2,4), imshow(C, [])
The goal is to complete the bottom right one.
  댓글 수: 2
Rik
Rik 2022년 12월 14일
Are you allowed to assume this is a perfect circle?
Alfredo Scigliani
Alfredo Scigliani 2022년 12월 14일
Let's say yes, I am

댓글을 달려면 로그인하십시오.

채택된 답변

prasanth s
prasanth s 2022년 12월 14일
remove noise using median filter
IM=medfilt2(P);
find gradient
[Gmag,Gdir] = imgradient(IM);
then apply circle detection or any other methds to separate the circle
  댓글 수: 4
Alfredo Scigliani
Alfredo Scigliani 2022년 12월 15일
How do I select the pixels after mask?
Rik
Rik 2022년 12월 15일
Logical indexing:
% load a builtin example image
load mri
im=squeeze(D(:,:,1,ceil(end/2)));
im=im2double(im);
subplot(1,3,1)
imshow(im)
title('original image')
[X,Y]=ndgrid(linspace(-1,1,size(im,1)),linspace(-1,1,size(im,2)));
R=sqrt(X.^2+Y.^2);
CircleMask = R>0.6 & R<0.8;
subplot(1,3,2)
imshow(CircleMask)
title('mask')
NewImage= 0.5*ones(size(im));
% copy data over with logical indexing
NewImage(CircleMask) = im(CircleMask);
subplot(1,3,3)
imshow(NewImage)
title('image with old values in mask')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by