WG: [Insight-users] Fltk image Viewer

Stephen R. Aylward aylward at unc . edu
Fri, 16 May 2003 12:29:25 -0400


Hi,

I'm glad the solution works for you - great!

Nice job of tracking it down.

In general, however, we have apps that update the image but want to keep 
the overlay, so I hesitate to apply your solution to the base class.

We'll provide the unset commands, but it is good that we don't need to 
rush now :)

s

salah wrote:
> Stephen,
> 
> I have solved the problem. 
> 
> It was the case that the new image will conflict 
> with the already existing overlay. My re-implemented 
> viewer can support (at the same time) five overlays 
> of different forms. In my viewer I have solved this 
> problem assuming the loading a new image to the viewer 
> will most probably need loading new overlay (especially,
> if the new image has different size.) 
> 
> So my solution is:
> 
> Simply, when a new image is loaded, any existing
> overlays should be removed!! This is done in the 
> method "...GlSliceView::SetInputImage()".
> In this method, the case of loading a new image 
> that has different size as the overlay will exit the 
> method, i.e, the loading will be aborted. I suggest
> that a more feasible treatment would be to remove
> the overlay and continue loaing the new image.
> I have cut this piece of code from my viewer, it shows
> the modifications that I did. 
> 
> 
> 
> template <class ImagePixelType, class OverlayPixelType>
> void MyGLSliceView<ImagePixelType, OverlayPixelType>::
> SetInputImage(ImageType * newImData)
> {
>     
>     RegionType region = newImData->GetLargestPossibleRegion();
>     if( region.GetNumberOfPixels() == 0 ) 
>       {
>       return;
>       }
> 
>     SizeType   size   = region.GetSize();
> 
> //  This was the case: the viewer reject a new image
> //  if its size is different form that of an existing
> //  overlay
> /*  
>     if( cValidOverlayData )
>       {
>       RegionType overlay_region = cOverlayData->GetLargestPossibleRegion();
>       SizeType   overlay_size   = overlay_region.GetSize();
>      
>       for( int i=0; i<3; i++ )
>         {
>         if( size[i] != overlay_size[i] )
>           {
>           return;
>           }
>         }
>       } 
> */
> 
> //  This is my solution:  remove overlays if they exist.
> //  I remove in this paragraph the first overlay.
>     if( cValidOverlayData1 ) {  
>        if(cWinOverlayData1 != NULL)  delete [] cWinOverlayData1;
>        cWinOverlayData1       = NULL;
>        cValidOverlayData1     = false;
> 	}
>     ... ...
>     ... ...
>     ... ...
> // no other modifications are needed. 
> 
> 
> I hope this could help if somebody faced such 
> a problem.
> 
> Best regards,
> 
> Zein
> =======================================================================
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: salah 
> Gesendet: Freitag, 16. Mai 2003 13:08
> An: 'Stephen R. Aylward'
> Betreff: AW: [Insight-users] Fltk image Viewer
> 
> 
> Hello Stephen,
> 
> YES, I am using an overlay image. I removed it
> for the sake of test and it worked just fine.
> 
> I traced the program with the overlay trying to
> find the error. My Viewer is actually a modified
> version of the GLColorSliceView. I used the following
> function to set an overlay image consisiting of 
> only one slice.
> 
> I have marked the statement at which the program
> abnormally terminates.
> 
> 
> template <class ImagePixelType, class OverlayPixelType>
> void MyGLSliceView<ImagePixelType, OverlayPixelType>
> ::SetInputOverlay3( OverlayType * newOverlayData )
> {
>   RegionType newoverlay_region = newOverlayData->GetLargestPossibleRegion();
>   SizeType   newoverlay_size   = newoverlay_region.GetSize();
>   
>   if( cValidImData && newoverlay_size[2]==1 )
>     {
>     cOverlayData3 = newOverlayData;
>     cValidOverlayData3 = true;
>     if(cWinOverlayData3 != NULL) 
>       {
>       delete [] cWinOverlayData3;       //    <<<<<<========  This is the statement ********
>       }
>     const unsigned long bufferSize = cWinDataSizeX * cWinDataSizeY * 4;
>     cWinOverlayData3 = new unsigned char[ bufferSize ];
>     this->update();
>     }
> }
> 
> 
> Could you please guess, what the problem could be.
> 
> Thanks,
> Zein
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Stephen R. Aylward [mailto:aylward@unc.edu]
> Gesendet: Donnerstag, 15. Mai 2003 20:48
> An: salah
> Cc: ITK Users
> Betreff: Re: [Insight-users] Fltk image Viewer
> 
> 
> Are you also setting an overlayImage?
> 
> Stephen
> 
> salah wrote:
> 
>>Hi,
>>
>>I am using a widget that inherits the GlSliceViewer. It works 
>>fine when it is provided with an input image ( using ->SetInputImage(...) )
>>for the first time.
>>
>>If I decided use the same widget with some other input image, i.e by 
>>calling ->SetInputImage(...) with some other image, then it works fine
>>only if the new image dimentions are less than or equall to the first one.
>>Otherwise, it reports a runtime error "Access Violation ....."
>>
>>Could any please help me solving this problem???
>>
>>Many thanks,
>>Zein
>>
>>
>>->8<------------->8<------------->8<------------->8<------------->8<------------->8<-
>>Zein I. Salah 
>>University of Tübingen, WSI-GRIS, Sand 14, 72076 Tübingen 
>>Email: salah@gris.uni-tuebingen.de
>>Tel.: (07071) 29 75465 (GRIS),           Fax: (07071) 29 54 66
>>
>>_______________________________________________
>>Insight-users mailing list
>>Insight-users@public.kitware.com
>>http://public.kitware.com/mailman/listinfo/insight-users
> 
> 
> 


-- 
===========================================================
Dr. Stephen R. Aylward
Associate Professor of Radiology
Adjunct Associate Professor of Computer Science and Surgery
http://caddlab.rad.unc.edu
aylward@unc.edu
(919) 966-9695