0
votes

Here is the matlab data, where I'm trying to modify the dicom image pixels.

The dicom image is of 4D, 3d for the Rgb image and other dimension represents the fames. I take each frame and I modify the some specific pixel values and I try to save them whole dicom image data in raw format.

The reason why I'm saving it in raw format is that I want to use this data as file in dcmodify command of dcmtk. So, my first question is, am I saving the raw data in correct format? If not, kindly suggest me how I should do so. Moreover, do you know whether or not dcmodify command dcmtk can handle 4d data like in this case or it can only modify just one single frame? Thanks.

clc
clear all
close all
img=dicomread('Bad001_2CH_01_anon.dcm');
%%implay(img);
[rows,columns,colors,frames]=size(img);
for i=1:frames
    img(1:25,:,:,i)=0;
    disp(i);
    figure(1)
    imshow(img(:,:,:,i))
end
fid=fopen('image.raw','w+');
cnt=fwrite(fid,img,'uint8');
fclose(fid);
2

2 Answers

0
votes

You may want to have a look at gdcmimg and or gdcmraw depending on what you really want to do

0
votes

You don't need raw data to use dmtk: "dcmodify is a tool that allows to modify, insert and delete tags and items in DICOM files."

Furthermore, raw data is desirable in very few and specific situations, as some metadata in the file saying what is in there and how it is stored helps a lot when a program has to read the information.

I've never used dmkt, but I guess that you should read the data with dicomread (as you do), modify it (as you do), and then save it as DICOM again with dicomwrite

To preserve the metadata in the DICOM you also need to extract the metadata with dicominfo, so you can put it back when you save the file.

img = dicomread('originalfile.dcm');
metadata = dicominfo('originalfile.dcm');

% do something with the img

% save altered DICOM with metadata
dicomwrite(img, 'processedFile.dcm', metadata, 'CreateMode', 'copy');

Then you can call:

dcmodify [options] writtenDicomFile

where writtenDicomFile is the name you used to save the file, and the [options] specify how are you altering the file.