Info

This question is closed. Reopen it to edit or answer.

Adding random numbers in dicom images using Matalb

1 view (last 30 days)
TA Almatani
TA Almatani on 16 Nov 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
I am modifying dicom images by replacing the actual pixel values with eight fixed numbers. Here is one line of my script (below).
image_list=dir('*.dcm');
for i=1:40
img=dicomread(image_list(i).name);
imgHdr = dicominfo(image_list(i).name);
%Bone
img(1:410,1:410) = 3000*uint16(img(1:410,1:410)>1590 & img(1:410,1:410) <=3000)+uint16(img(1:410,1:410)<=1590 | img(1:410,1:410)>2000).*img(1:410,1:410);
dicomwrite(img, ['N' num2str(i) '.dcm'], imgHdr,'CreateMode','Copy')
end
Then, I am trying to add random numbers (between 1 and 100) to only one fixed values, i.e. 3000 (as shown in the script) so it will be between 3000 and 3100 and the other fixed numbers are still the same. I tried
img(1:410,1:410)= img(1:410,1:410) +randi([3000 3100],410,410);
but it didn't work. How can I do that ?
Any assistance would be appreciated, thanks.
TA

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!