3-D image matrix made from 2-D MRI images

1 回表示 (過去 30 日間)
Vojtech Raska
Vojtech Raska 2020 年 3 月 13 日
コメント済み: Image Analyst 2020 年 3 月 13 日
Hi, i´m using this code to make 3-D matrix of 2-D MRI images, but if I load more than 3 images that every image besides firts three and the last one is just black and all values of that matrices are zeros. The images are uint8 format. I tried to trasfer them to double but it didn´t work. Is there some solution or the image matrices can be only three for each other?
clc; clear all; close all;
[Name, Path] = uigetfile('*.*', 'All Files (*.*)','MultiSelect','on');
if ~iscell(Name)
Name = {Name};
end
%% matrix
for i = 1:1:length(Name)
Nazev = Name(1,i);
Nazev = char(Nazev);
Img_info = [Path Nazev];
Img = imread(Img_info);
Img(:,:,i) = double(rgb2gray(Img));
end
  2 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 3 月 13 日
If possible, can you attach a few sample images? It will help in figuring out the error.

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 3 月 13 日
編集済み: Ameer Hamza 2020 年 3 月 13 日
You are replacing the value of Img inside the for loop. The matrix is rewritten at the next iteration. Try this
clc; clear all; close all;
[Name, Path] = uigetfile('*.*', 'All Files (*.*)','MultiSelect','on');
if ~iscell(Name)
Name = {Name};
end
%% matrix
for i = 1:1:length(Name)
Nazev = Name(1,i);
Nazev = char(Nazev);
Img_info = [Path Nazev];
Img = imread(Img_info);
Img_matrix(:,:,i) = rgb2gray(Img);
end
montage(Img_matrix)
  13 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 3 月 13 日
Glad to be of help.
Image Analyst
Image Analyst 2020 年 3 月 13 日
Can you please "Accept this answer" to give Ameer reputation points for helping you? Thanks in advance.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by