I have mha file, how to do image segmentation of this data
8 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/168840/image.jpeg)
This is in continuation to a previous que which I already asked regarding readdata3d. dont know how to proceed further.....
Sir here is the data attached of brain mri scan. It's in mha format and is a 3d Image. We have to convert this 3d into a 2d image and use watershed algorithm to detect the tumor in the brain. The mha format is not being supported. Hence I am not able to upload it. If any email id is given I would send it.
I've used the following code:
[V,info]=ReadData3D
for slice = 1 : numberOfSlices
thisSlice = V(:,:, slice);
baseFileName = sprintf('Slice %d.png', slice);
fullFileName = fullfile('F:\final yr project', baseFileName);
imwrite(thisSlice, fullFileName);
end
The final image should be like the one I attached above.
The image should be gray scale analysed. So how to use these mha files to covert the 3d to above mentioned like pic. For further analysis using watershed
Can you please suggest me how this can be done and also can you please help me with the code if possible
31 个评论
rohith bharadwaj
2018-1-14
I have a .mha file. I have to do watershed segmentation on the data to find a tumour. I don't know how to start. I am not able to handle .mha files. Ive tried ReadData3D but I'm getting an error, not able to resolve. how to import .mha files to matlab, plot them, covert the 3D image into many 2D images by slicing the 3D image into different layers
Jan
2018-1-14
Are you talking about https://www.mathworks.com/matlabcentral/fileexchange/29344-read-medical-data-3d? Please post much more details.
rohith bharadwaj
2018-1-14
编辑:Walter Roberson
2018-1-15
ive typed ReadData3D in command window and loaded the .mha file.
I'm getting as:
RescaleSlope not available, assuming 1
RescaleIntercept not available, assuming 0.
also tried
[V,info]=ReadData3D('abc.mha');
but getting as : could not open file abc.mha
Is there any other method for analysis of .mha files
rohith bharadwaj
2018-1-14
I tried [V,info]=ReadData3D I got data in V and info
V is of order 240x240x155
and info is of 1x1
Now how to proceed further. how to plot V, convert this data into different layers(2D IMAGE by slicing)
Jan
2018-1-14
@rohith: Please be so kind and explain, which function you are using. "readdata3d" is not a built-in function. If you use a 3rd party tool, the readers have to know this.
The message "could not open file abc.mha" might mean, that there is no file with this name in the current folder. Perhaps you have to specify the complete path?
If you get your V as [240 x 240 x 155] array, you get the k.th slice by V(:, :, k).
rohith bharadwaj
2018-1-14
I don't know much about the function. but this line of code is not working every time. Is there any similar function in matlab to get similar output. readdata3d enables us to use .mha files. Is there another method to handle these extension files in matlab
Image Analyst
2018-1-14
ReadData3D is not a built-in function. Contact whomever gave you the .mha files and ask them if they have a reader for their files that works.
Jan
2018-1-14
@rohith: While you do not know much about the function, I do not know anything about it. I asked twice already for an explanation where you got this function from. Unfortunately you do not reveal this important detail. How could we know, if there is another tool, if you do not tell us, which tool you are using? How could we know a tool to get a similar output, without knowing to what it should be similar?
In addition your comments sound like you were able to import the file successfully already. So why are you looking for a different tool? I think your current problem is the plotting. Then please explain the details of what you want to plot how.
Image Analyst
2018-1-14
Here are 51 posts about mha files: https://www.mathworks.com/support/search_results.html?q=mha&submitsearch= I'm sure you can find something that works within those posts.
If a given mha reader only works for some files, then perhaps your reader and files don't match up as far as "flavors" of mha files that they work with. Try a different reader or make sure that your mha file is created with all the information that your reader expects to find.
rohith bharadwaj
2018-1-15
sir can you share your email id so that I can share my codes and explain my work in detail
thank you
Walter Roberson
2018-1-15
RescaleSlope not available, assuming 1
RescaleIntercept not available, assuming 0.
Those are not errors. Dicom images have properties by those names that are used to make it practical to store floating point values as linear integer values instead, and the messages are just telling you that the data file you were reading does not make those properties available and will be interpreted "as-is". These properties mostly make a difference for CT images; you probably do not care about them.
Walter Roberson
2018-1-15
It is not up to me to provide the email address for Image Analyst. I know from past discussions that he does not email for these purpose: he would neither send nor receive email on these topics.
rohith bharadwaj should post the link to the ReadData3D that they are using, and if permitted, should attach the mha file (it would be necessary to zip it.)
Rik
2018-1-15
Sorry for the misunderstanding. I meant that rohith bharadwaj could just post the text of his e-mail here, instead of sending it to only Image Analist. If he is allowed to share it by e-mail, he should be allowed to post it here.
rohith bharadwaj
2018-1-15
Sir here is the data attached of brain mri scan. It's in mha format and is a 3d Image. We have to convert this 3d into a 2d image and use watershed algorithm to detect the tumor in the brain
rohith bharadwaj
2018-1-15
编辑:Walter Roberson
2018-1-16
I've used the following code:
[V,info]=ReadData3D
for slice = 1 : numberOfSlices
thisSlice = V(:,:, slice);
baseFileName = sprintf('Slice %d.png', slice);
fullFileName = fullfile('F:\final yr project', baseFileName);
imwrite(thisSlice, fullFileName);
end
rohith bharadwaj
2018-1-15
The image should be gray scale analysed. So how to use these mha files to covert the 3d to above mentioned like pic. For further analysis using watershed
rohith bharadwaj
2018-1-15
Can you please suggest me how this can be done and also can you please provide me with the code if possible
Jan
2018-1-15
@rohit: I do not see attached data. You still keep it as a secret, which "ReadData3D" function you use and you simply ignore my corresponding questions. This is a strange behavior if you ask for assistance.
It is not clear what you are asking for now. Does the posted code work? It is not possible to post useful code based only on the description: "further analysis using watershed".
Please read and consider the link Rik has suggested 18 comments before: https://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer . Your current way of asking does not allow to help you and therefore this wastes your time only. The members of the forum really do like to help you, but give them a chance to do this.
rohith bharadwaj
2018-1-15
Sir I wanted to post the data. But it is in mha format. Hence the file isn't uploading. Could you give any mail id so that I can send you the data
rohith bharadwaj
2018-1-15
编辑:rohith bharadwaj
2018-1-16
I want to use
baseFileName = 'bac.mha';
fullFileName = fullfile('F:', baseFileName)
I am getting these errors
Error using imread (line 350) Unable to determine the file format. Error in brainana (line 34) grayImage = imread(fullFileName);
Im getting black white images when took one image. but i have to do my analysis on grayscale image. the mha data should be converted to 2D similar to image attached above.
Image Analyst
2018-1-16
Come on rohith, you need to think a little before you do things. Now you know that imread() does not work with .mha files and your ReadData3D() function does work with them - you've already told us that. So why didn't you change from imread() to ReadData3D() in the demo???
rohith bharadwaj
2018-1-16
编辑:rohith bharadwaj
2018-1-16
You are not getting my point. ReadData3D is giving 240x240x155 matrix. Ive sliced that to form a 2D image. but the image is in black and white(Slice 80.png attached). I dont want that image. I want greyscale image shown above for analysis. Its not compulsory to use ReadData3D. if there is any other better or easy way of approach Please let me know. I just want to convert that 3d to 2d grayscale images. After that i'll use watershed to detect tumour
Image Analyst
2018-1-16
How do you want to convert it? Take the mean along the slice direction? Take the maximum intensity projection? Take just one slice? I have no idea.
采纳的回答
Walter Roberson
2018-1-16
Your data is not black and white. It is, however, in CT units, with values from 0 to 1509. To make visual sense out of that you need to rescale it. Use this:
V = mat2gray(V);
after you read the data in. That will scale the values in the array so that the maximum value is 1 and the minimum is 0. You can then extract slices and imshow() or image() them.
13 个评论
rohith bharadwaj
2018-1-16
Yes Thank you I got my 2d grayscale image.
Is there any watershed algorithm to find the tumour.
Walter Roberson
2018-1-16
"L = watershed(A) returns a label matrix L that identifies the watershed regions of the input matrix A, which can have any dimension"
Dileep Kumar Kothamasu
2018-3-12
I used the same code as mentioned above and I got 176 slices. so which slice can be used for preprocessing and segmentation. Or should we use whole 176 slices for preprocessing and segmentation if so how to do it.please attach the code if available or comment the solution
Walter Roberson
2018-3-12
Any slice that has content can be used for preprocessing and segmentation. Some slices will not happen to have the feature you are interested in, but you need to do pre-processing and segmentation in order to figure out what the slice does have.
Dileep Kumar Kothamasu
2018-3-12
I didn't get you. Can you briefly describe that? Do you mean we have to consider all the slices?
Walter Roberson
2018-3-12
When you look at any given slice, how do you know whether it contains whatever it is you are looking for?
Dileep Kumar Kothamasu
2018-3-13
编辑:Dileep Kumar Kothamasu
2018-3-13
Ya That's what my doubt is to so how can I know which slice can be used? suppose in one image slice no. 80 looks fine and in another image slice no. 96 looks good so should I use slice no's 80 and 96 for preprocessing and segemtation and I am not sure about 80 and 96 slices are good because 80,81,82 slices are good with small variations in brain size so I confused can you help me in this?
Image Analyst
2018-3-13
Yes, you can use the whole 3-D volumetric image (all slices stacked together). That's what "which can have any dimension" means - 3-D as well as 2-D images are allowed.
Dileep Kumar Kothamasu
2018-3-15
Thank You, So how can I take whole slices stacked together go for further process
Dileep Kumar Kothamasu
2018-3-17
Walter code helped me to rescale them only.I don't know which slice I have to get feature extraction technique. Please help me. I got stuck on this problem and didn't move forward!!
Walter Roberson
2018-3-17
The researchers I worked with generally normalized the brain images, and then after that trained on a bunch of normal brains and a bunch with tumors. They did not use segmentation and preprocessing that I recall. But it has been over 15 years since I did any brain related work, and I was not much involved with the brain analysis theory (I was more responsible for interface and graphics and general program structure for the brain work.)
Image Analyst
2018-3-17
Because of your ambiguous posts, we don't know if you want to segment the 3-D volume, or if you want to segment out a 2-D region in just one slice. Why don't you start your own question, rather than keep bugging rohith, and post some of your slice images? click here
更多回答(1 个)
Image Analyst
2018-1-15
It looks like you got the mha reading part working so now you just need to find the tumor. Assuming it's bright, just threshold and call regionprops. It works in 2-D or 3-D. See attached demo.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
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 (한국어)