- What is the 3rd dimension of the image? Is your array actually a stack of images. Your figures only show a 2D image.
- The gaps to be filled are the vertical black lines or the horizontal band in the middle, or something else?
- To identify your edge, can we assume that the middle band is always in the centre of the image and always the same width? Do you know the actual width?
- giving us an actual image instead of a figure would help
2D / 3D Interpolation (Linear or Spline ) for image - Matlab
3 次查看(过去 30 天)
显示 更早的评论
Alina tom
2018-5-5
Hi all
I have a image (Given Below) it is a 3d image have size 512x271x512 . I want to apply interpolation on the missing part.

I want to apply interpolation on that image to fill the gap and after it I have to calculate the edge points of the image like this
and want to get the edge of the surface like shown in output image

can anyone please guide me . how I can do this . Thanks in advance for your help
13 个评论
Guillaume
2018-5-15
编辑:Guillaume
2018-5-15
Alina tom
2018-5-15
编辑:Guillaume
2018-5-15
Yes this a stack of images . actually my image is in circular from and I have converted the image to its sagittal view . here is my code for converting the image
my actual image consist of 271 frames
Img = uint8(zeros(512,512,271)); % preallocate 4-D array
for frame=1:271
[Img(:,:,frame),map] = imread('image.tif',frame);
end
sno = size(Img); % image size
sno_a = sno(3); % number of axial slices
S_a = round(sno_a/2);
sno_s = sno(2); % number of sagittal slices
S_s = round(sno_s/2);
sno_c = sno(1); % number of coronal slices
S_c = round(sno_c/2);
S = S_a;
sno = sno_a
ImgSg = flip(permute(Img, [1 3 2]),2); % Sagittal view
S = S_s;
sno = sno_s;
imshow(squeeze(Img1(:,:,S,:)));
by gap mean vertical black lines . that are filled by the information of continuous edge .
The middle band is always in the center of image and its width is between this value 225:286,1:271,:
actual image can be downloaded from this link
Guillaume
2018-5-15
Your code is a bit confusing, there's a lot of variables you create that are not used. More importantly, it's not clear what the Img1 you pass to imshow is. It looks like you've unrolled each frame but it's not what the code you posted does.
Alina tom
2018-5-15
I have created these variables to get different view like to get XZ view and YZ view . In imshow I'm using the slice column from where I have to cut the image . here I have attached the output of this code before and after removing the middle part. now I want to fill the gap and after filling the gap I want to get the edge information smoothing like this



Alina tom
2018-5-15
I have converted the image into binary and then cut the image from middle into upper and lower part and try to find the 1st non zero element and then fill the previous part with white pixels . but its not working . can you please see my code where I'm doing wrong
if true
Kmedian = imgaussfilt(Img1,[1 1]);
[counts,x] = imhist(Kmedian,16);
T = otsuthresh(counts);
BW = imbinarize(Img1,T);
[rows, columns, numberOfColorChannels] = size(BW);
middleRow = floor(rows/2);
topHalf = BW(1:middleRow, :,:);
bottomHalf = BW(1+middleRow:end, :,:);
filterImg = bwareaopen(bottomHalf,25);
output_img = zeros(size(bottomHalf));
for col = 1: size(bottomHalf,2)
first_nnz_row = find(filterImg(:,col),1,'first');
output_img(first_nnz_row:end,col) = 1;
end
figure, imshow(squeeze(output_img(:,:,S,:)));
filterImg = bwareaopen(topHalf,25);
output_img1 = zeros(size(topHalf));
for col = 1: size(topHalf,2)
first_nnz_row1 = find(filterImg(:,col),1,'last');
output_img1(1:first_nnz_row1,col) = 1;
end
figure, imshow(squeeze(output_img1(:,:,S,:)));
end
Guillaume
2018-5-15
Can you attach, as a mat file, not a screenshot of a figure, the actual Img1 that you use to test your code? As it is, it is difficult to understand what each step is doing.
Note that since BW is a binary image, hence 2D, numberOfColorChannels is unneeded in:
[rows, columns, numberOfColorChannels] = size(BW);
This is simpler:
[rows, columns] = size(BW);
Also, you create a 2D output_img and fill it in a loop. Therefore,
imshow(squeeze(output_img(:,:,S,:)))
is just
imshow(output_img)
if S == 1, and an error otherwise.
Alina tom
2018-5-16
https://drive.google.com/open?id=1p6_JsehMsoxz-spTxA84f08AjVwideCC This is the link For Img1 in mat formate
Alina tom
2018-5-16
How I can read the pixels along the curve structure like in image and draw a line on it like in this picture and also want to fill the gaps along the curve . can you guide me

Guillaume
2018-5-17
This is the link For Img1 in mat formate
If I load that mat file and then do
imshow(Img1(:, :, 1)) %or using any other index for the 3rd dimension
I get nothing that resembles your image at all.
Alina tom
2018-5-17
Sir can you guide me how I fuse/ combine two images . one image is 2d having dimensions 512x271 and other image is 3d having dimensions 512x271x512. I want to combine them to make one image . the output image have size 512x271x512
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)