How to replace small section of image with other values within the image?

9 ビュー (過去 30 日間)
Anon
Anon 2020 年 2 月 8 日
コメント済み: Image Analyst 2020 年 2 月 8 日
Hi,
I have a small artifact within my tissue image that I would like to replace with values from the surrounding tissue. However, I do not want a uniform region to replace the artifact. So far I have the code below, which gives me the following image. However, as you can see that it does not line up for replacing the values. I am confused on what to do, I have tried image segmentation but have not got any further either. Any help would be greatly appreciated!
The first half of the code can be ignored, as I am trying to open up multiple files.
Screenshot 2020-02-08 at 15.53.53.png
clear all
ROI = [ 1350 1550 750 950];
%A=input('type in pixel value for artifact');
for k = 1:100
fileName = sprintf('paganin_000100.png', k);
if isfile(fileName)
% If the file exists, display it.
imageData = imread(fileName);
%crop
imageData = imageData(ROI(1):ROI(2),ROI(3):ROI(4));
%imshow(imageData);
imageMatrix(:,:,k) = imageData;
else
% Print alert for those files that don't exist.
fprintf('File not found: "%s".\n', fileName)
end
end
grayImage = imageData;
I = grayImage;
Rv = [54:154; 67:167; 41:141; 80:180]; % Row Start Matrix
% Column Vector
Rc = 0:15; % Row Subscript Address Length
Cv=16:116
for k=1:100,
j=100
I(Rv(1,k)+Rc,Cv(j)) = I(Rv(3,k)+Rc, Cv(j));
I(Rv(2,k)+Rc,Cv(j)) = I(Rv(4,k)+Rc, Cv(j));
end
imshow(I)

採用された回答

Image Analyst
Image Analyst 2020 年 2 月 8 日
Try regionfill() to "smear in" the surrounding vaules to the inside of the region.
  2 件のコメント
Anon
Anon 2020 年 2 月 8 日
編集済み: Anon 2020 年 2 月 8 日
c = [131 136 2 12];
r = [108 126 75 56];
BW = roipoly(I,c,r);
imshow(I)
figure
imshow(BW)
J=regionfill(I,BW)
imshow(J)
I have tried this but it does not do what I would like as the metal wire is still present there
Image Analyst
Image Analyst 2020 年 2 月 8 日
Try making your BW mask larger.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBiomedical Imaging についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by