How do I exemplify this function through a script?

1 visualizzazione (ultimi 30 giorni)
Joao Joao
Joao Joao il 9 Gen 2022
Commentato: Joao Joao il 13 Gen 2022
Hello everybody. I hope you are ok. This function was given to me, read_segmentation(), and now I have to develop a script that exemplifies the use of this function.
This function for a given exam and patient, allows theuser chooses an anatomical structure (within the available segmentations) and displays it graphically. The regions of interest (eg lungs) must be represented at the level of original intensity and pixels that do not match the regions of interest must be represented in black.
I have an excel file.
I know it's a little long but if you could help me I would appreciate it.
Thanks
function [image]=read_segmentation(CXRID)
reply = input (['Are you sure the exam ID(' CXRID ') is correct?:\n1)Yes\n2)No\n']); % Confirm that the written exam ID is correct,
switch reply % dando a opportunity to correct it if it is incorrect.
case {1}
disp('');
case {2}
CXRID=input('Re-enter exam ID:','s');
end
[~,CID] = xlsread ('Data.xlsx','Sheet2','A2:A21');%Import of values to put in field 'CRX_ID'
[~,dateC] = xlsread ('Data.xlsx','Sheet2','B2:B21');%Importing the values to be placed in the 'Date' field
[~,PIDC] = xlsread ('Data.xlsx','Sheet2','C2:C21');%Importing the values to put in the 'Patient_ID' field
[~,Rep] = xlsread ('Data.xlsx','Sheet2','D2:D21');%Importing the values to be placed in the 'Report' field
ImageData = struct('CRX_ID',CID,'Date',dateC,'Patient_ID',PIDC,'Report',Rep);
d=struct2cell(ImageData); % Converts the data structure of exams to cell format, which will facilitate operations.
e=size(d); % Determines the number of existing rows and columns of cells.
j=0; % Set j=0, which will allow you to check if the exam ID exists in the database
for f=1:e(2) %In this cycle, the written exam ID will be checked.
if d(1,f)==CXRID; %exists in the database, by comparing this
j=1; %string with the existing strings of the cells in row 1
else
k=0;
end
end
if j==1
msg = "Want to see the heart or the lungs"; %Already in this cycle, by opening a menu.
opts = ["Lungs" "Heart"]; %the user will be able to choose the structure that
choice2 = menu(msg,opts); %intends to analyze.
if choice2==1
d1='lungs'
else
d1='heart';
end
D=dir(strcat(CXRID,'_',d1,'.png')) % Returns a structure with data referring to the name of the written file, its location, its date, etc.
if size(D)==[0 1] % Analyzes whether this file exists in the database. If it does not exist, its dimension will be [0 1].
error('The person has not taken to this anatomical structure!')
else
E=string(strcat(CXRID,'_',d1,'.png')); % Joins all the text segments to create a single variable with the full name of the image we want to open.
A=imread(strcat(E)); % Reads the image in black and white and a matrix is created.
B=imread(strcat(CXRID,'.png')); % Reads the entire exam image and a matrix is created.
C=zeros(2048,2048);
for o=1:2048
for p=1:2048 %Cycle through which the white pixels of image A (segment of the anatomical structure) are replaced,
if A(o,p)==0 %by the original pixels of the full scan, with the black pixels remaining.
C(o,p)=0;
else
C(o,p)=B(o,p);
end
end
end
newmatrix = rescale(C, 0, 255); % The image is scaled so that the values are between 0 and 255(RGB)
newmatrix = uint8(newmatrix); %The double matrix is converted to uint8.
image=imshow(newmatrix, []); % Exposure of the previously read image.
end
end
end
  11 Commenti
Bjorn Gustavsson
Bjorn Gustavsson il 12 Gen 2022
You will first have to learn how to use the function in all possible ways, then describe that and whatever (pre and post) processing that is associated with that. There will not be much else we can say about this topic without pretty much doing the same...

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Images in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by