crop the base image from the mask

hi, I have a base image and a mask image (both are 3d medical Images)in .mhd format.I have the code to read my image in the above format. Can anyone provide me help in cropping my base image with the mask.
Thanks

 채택된 답변

Image Analyst
Image Analyst 2012년 1월 12일

1 개 추천

To crop, you can calculate the top, bottom, left, and right columns of the mask's "true" area by using any(). Then use
croppedImage = fullImage(row1:row2, col1:col2);
or you can use imcrop().

댓글 수: 3

kittu
kittu 2012년 1월 12일
Hey thanks for the answer. But my target and mask images are 3D. I used the imcrop after extracting a slice from my target image using y(1:,:,).Unfortunately,when i use imcrop, it gives me error regarding unsupported dimension. Secondly, i have no clue about your fullImage function.Please suggest.
Thanks
Image Analyst
Image Analyst 2012년 1월 12일
You might be able to extend that concept to a 3D image, just add a slice1:slice2 dimension to the fullImage() index list. fullImage is the name of your image array, not a function. Please verify that you want cropping (to the maximum extents of the mask), and not simply masking the data with your mask - they're very different things.
kittu
kittu 2012년 1월 12일
hey thanks for the solution.i got the solution.just by element by element multiplication of the base image and mask image,I was able to crop the base image with the mask image..
thanks for the help.
crop(i,:,:)=double(mask(i,:,:)).*double(image(i,:,:))

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2012년 1월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by