Hello, can someone suggest me, that how i can implement ROI MASKING along morphological filtering.
조회 수: 1 (최근 30일)
이전 댓글 표시
i upload the some code along with resulted image, my request to help me here how to creat ROI mask, here the need to separate the segmented area, and morphological filtering is employed small spurious brights regions (having redius of less the 3*3 pixels are removed from LV walls.
Code
%%I=dicomread('IM_0001.dcm'); %%subplot(3,4,1);imshow(I);title('Scan Image ');
input=imread('A001.jpg'); subplot(3,4,1);imshow(input);title('input image '); %% covert the input image into binary and then resize the image automatic for automatic ROI Detection %%and crop the localized image J=imresize(input,0.5,'nearest');
h=imrect(gca,[100 94 162 146]); setResizable(h,0) position=wait(h); Crop=imcrop(input,position); level=graythresh(Crop); BW=im2bw(Crop,level); j=imresize(BW,5.2); subplot(3,4,2);imshow(Crop);title('localize Image');
J=imadjust(Crop,stretchlim(Crop),[]); load clown X=ind2gray(J,map);
subplot(3,4,3);imshow(X);title('Apply Threshold'); %% apply complment Complement=imcomplement(X); subplot(3,4,4);imshow(Complement);title('Complement'); %% apply histogram equalization and solve the probelm of intensity normalization for prpose %%automatic segmentation technique numofpixels=size(X,1)*size(X,2); HIm=uint8(zeros(size(X,1),size(X,2)));
freq=zeros(256,1);
probf=zeros(256,1);
probc=zeros(256,1);
cum=zeros(256,1);
output=zeros(256,1); %freq counts the occurrence of each pixel value.
%The probability of each occurrence is calculated by probf.
for i=1:size(X,1)
for j=1:size(X,2)
value=X(i,j);
freq(value+1)=freq(value+1)+1;
probf(value+1)=freq(value+1)/numofpixels;
end
end
sum=0;
no_bins=255; %The cumulative distribution probability is calculated.
for i=1:size(probf)
sum=sum+freq(i);
cum(i)=sum;
probc(i)=cum(i)/numofpixels;
output(i)=round(probc(i)*no_bins);
end
for i=1:size(X,1)
for j=1:size(X,2)
HIm(i,j)=output(X(i,j)+1);
end
end
subplot(3,4,5);imshow(HIm);title('Intensity Normalization'); %The result is shown in the form of a table
figure('Position',get(0,'screensize'));
dat=cell(256,6);
for i=1:256
dat(i,:)={i,freq(i),probf(i),cum(i),probc(i),output(i)};
end
columnname = {'Bin', 'Histogram', 'Probability', 'Cumulative histogram','CDF','Output'};
columnformat = {'numeric', 'numeric', 'numeric', 'numeric', 'numeric','numeric'};
columneditable = [false false false false false false];
t = uitable('Units','normalized','Position',[0.1 0.1 0.4 0.9], 'Data', dat,'ColumnName', columnname,'ColumnFormat', columnformat,'ColumnEditable', columneditable,'RowName',[]); %% a bit change need when an input image is not in 2D shape Simplegrayimage=rgb2gray(X); subplot(2,2,2); bar(Simplegrayimage);
title('Before Histogram equalization');
subplot(2,2,4); bar(HIm);
title('After Histogram equalization');
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!