'horzcat' error when using dicomread() within a for-loop

조회 수: 1 (최근 30일)
Roman Hochuli
Roman Hochuli 2011년 2월 21일
편집: Walter Roberson 2017년 1월 22일
Hi
I have a set of 460 DICOM files that I would like to read in one-by-one, subtract 1000 from each pixel, and write them out as DICOM files. I have tried the following code, but continue to get an errror saying "CAT arguments dimensions are not consistent":
I=zeros(512,512);
for i=0:459
I=dicomread(['IMG (' int2str(i) ').dcm']);
I=im2double(I);
I=I-(1000*ones(size(I)));
I=int16(I);
dicomwrite([I,'IMG (' int2str(i) '.dcm'])
end;
I assume this problem comes from a line in dicomwrite(), but I can't work out how to change this.
Any suggestions would be much appreciated.
Thanks,
Roman

채택된 답변

Richard
Richard 2011년 2월 21일
In the call to dicomwrite you have tried to concatenate the matrix of pixel data (I) with the name of the file - basically, you put the "I," in the wrong place. Also, I noticed that you've removed a ")" in the output filename that you probably meant to keep? Try this to write back to the same file:
dicomwrite(I, ['IMG (' int2str(i) ').dcm'])
  댓글 수: 1
Roman Hochuli
Roman Hochuli 2011년 2월 21일
Thank you for your answer.
I don't know why I didn't spot that earlier.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by