|
Hi guys,
Although I stopped thinking about the multiframe dicomwrite beacuse of other commitments, reading your updates makes me want to handle again this issue.
I tried the solution suggested by LB and it works fine!
Of course, you cannot guaranteed about DICOM specs validation, but in my opinion it's a good solution to be used for unofficial or academic purposes.
I agree with you: an official and validated MATLAB implementation of this functionality would be great!
Just a clarification for Kamlesh: maybe you've already suceeded in making it work, but if not... see below!
The instructions that LB gave us are corrected, but the following oversight:
in the dicom_encode_jpeg_lossy.m file, also del line fragments{1}=..... need to be changed in order to take into account the p parameter.
See below.
frames = size(X,4);
for p = 1:frames
tempfile = tempname;
imwrite(X(:,:,:,p), tempfile, 'jpeg');
.....
fragments{p} = fread(fid, inf, 'uint8=>uint8');
%fragments{1} = fread(fid, inf, 'uint8=>uint8');
%frames = 1;
.....
end
Hoping this helps!
Thank you guys!
Best regards,
Sara.
"K P" <kamleshprakash.p@gmail.com> wrote in message <ig2dh1$np7$1@fred.mathworks.com>...
> Hi Lead Bucket,
>
> Could you please give me more info on the code for multiframe dicomwrite. I am creating a multiframe dicom file with several tif images.
> I tried the changes in the two functions as you mentioned but how am i suppose to add multiple frames using dicomwrite function( ie. in the programme code what is the syntax for adding multiple frames at a time). I am still ale to add only one frame.
> Looking forward for your help.
>
> Thank You
> Kamlesh
>
> "Lead Bucket" wrote in message <i256tn$gj5$1@fred.mathworks.com>...
> > "lovely_m M" <lovely_m@hotmail.nl> wrote in message <i0f3qn$eng$1@fred.mathworks.com>...
> > > Hi Lead Bucket,
> > >
> > > Great that you figured it out :) I've been trying to modify the functions according to your description but I can't get it to work. Could you maybe post the exact changes you made?
> > >
> > > Many thanks,
> > > M
> >
> > Hi M,
> >
> > First, I created a copy of the private directory .../toolbox/images/iptformats/private and dicomwrite so I didn't muck things up with the original version. Then, in the dicom_encode_jpeg_lossy.m file, I modified frames to reflect the true number of frames and added a for loop:
> >
> > frames = size(X,4);
> > for p = 1:frames
> > tempfile = tempname;
> > imwrite(X(:,:,:,p), tempfile, 'jpeg');
> > .....
> > %frames = 1;
> > .....
> > end
> >
> > Next, in dicomwrite.m I commented out the for loop that cycled through the frames, removed the dependency of X on p, and changed the destination to filename, all in the write_message subfunction:
> >
> > .....
> > %for p = 1:num_frames
> > .....
> > [attrs, msg, status] = dicom_create_IOD(SOP_UID, X, map, ...
> > .....
> > [attrs, msg, status] = dicom_copy_IOD(X, map, ...
> > ,....
> > destination = filename;
> > %destination = get_filename(filename, p, num_frames);
> > .....
> > %end
> >
> > That was it. It seemed to work fine for me here, although I was using the 'copy' option. I didn't test it for the other options. It gave me one or two warnings on one of the dicom variables not being correct, but I was okay with that.
> >
> > Hope this works for you!
> > -LB
|