- 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
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
2D / 3D Interpolation (Linear or Spline ) for image - Matlab
3 views (last 30 days)
Show older comments
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 Comments
Guillaume
on 15 May 2018
Edited: Guillaume
on 15 May 2018
Alina tom
on 15 May 2018
Edited: Guillaume
on 15 May 2018
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
on 15 May 2018
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
on 15 May 2018
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
on 15 May 2018
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
on 15 May 2018
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
on 16 May 2018
https://drive.google.com/open?id=1p6_JsehMsoxz-spTxA84f08AjVwideCC This is the link For Img1 in mat formate
Alina tom
on 16 May 2018
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
on 17 May 2018
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
on 17 May 2018
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
Answers (0)
See Also
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)