From: Ian S. <ian...@st...> - 2003-08-12 17:29:01
|
> -----Original Message----- > From: Ian Scott [mailto:ian...@st...] > Sent: Thursday, August 07, 2003 10:55 AM > To: 'Mark Johnson' > Subject: RE: quick vil question > > > Use the vil_memory_image class. It is a vil_image_resource > that stores its image data in memory. You could use a > put_view to have them point to equivalent data. However, the > code at present doesn't allow you to have them point to the same data. > > In order to fix this, I suggest you add the following. > > Add another friend constructor function to vil_memory_image > (and put the definition in vil_memory_image.cxx) > vil_image_view_sptr vil_new_wrap_memory_image(vil_image_view &im) > { > sptr = new vil_memory_image(...); > sptr->view_ = im; > return im; > } > > Please add a test of the new function to test_image_resource.cxx > > This should suffice for your needs. If you need more, then > bear in mind that I am reluctant to add explicit access > functions to the internal vil_image_view. This is despite the > normal VXL convention that core class APIs include well > defined access to fixed internals. In the case of the > vil_image_resource classes, I think their general complexity, > and lack of perfection (almost none of the file format > resources could be considered complete) means that we are > better to hide implementation in the normal OO way. > > > Thanks, > Ian. > > > > -----Original Message----- > > From: Mark Johnson [mailto:mr...@le...] > > Sent: Wednesday, August 06, 2003 10:07 PM > > To: sc...@us... > > Subject: quick vil question > > > > > > i recently switched from using vil1 to vil, and i've been > > looking for a > > way to get a vil_image_resource_sptr from a vil_image_view > (such that > > both refer to the same image data). is it possible to > perform such a > > 'conversion'? if so, what's the easiest way to do so? > > > > thanks, > > Mark Johnson > > mr...@le... > > > |
From: Amitha P. <pe...@cs...> - 2003-08-12 18:48:11
|
Mark Johnson wrote: >> i recently switched from using vil1 to vil, and i've been looking >> for a way to get a vil_image_resource_sptr from a vil_image_view >> (such that both refer to the same image data). is it possible to >> perform such a 'conversion'? if so, what's the easiest way to do >> so? Ian Scott replied: > Use the vil_memory_image class. It is a vil_image_resource > that stores its image data in memory. You could use a > put_view to have them point to equivalent data. However, the > code at present doesn't allow you to have them point to the same > data. Does it make sense to try to get a vil_memory_image from a vil_image_view in general? The whole point about a image_view is that the data may not be contiguous, the steps may be negative, etc. A single pointer to a location of memory will not capture the information in the image_view except for a extremely restricted, albeit common, set of views. Perhaps the solution is a vil implementation of vgui_generic_image_view? I implemented this recently because I wanted to store a view without storing the type. For the vgui case, I had to do run-time type checks to convert to a pixel buffer anyway, so "storing" the compile-time type information in the vil_image_view without using member templates just lead to interface clutter. A vgui_generic_image_view stores all the information in a vil_image_view: the steps, the base memory pointer, and pixel format. It does not have compile time information. It is very much designed for the limited use in vgui, but it could be extended to be more general. The biggest issue that arises is converting back to a vil_image_view with compile time information. Perhaps extending (overloading) vil_convert_cast to handle a generic view would do it. Otherwise, we could add it to the list of acceptable arguments in the vil_image_view constructor and operator=. Amitha. |
From: Ian S. <ian...@st...> - 2003-08-13 16:16:13
|
> -----Original Message----- > From: Amitha Perera [mailto:pe...@cs...] > Subject: Re: [Vxl-maintainers] FW: quick vil question > > > Mark Johnson wrote: > >> i recently switched from using vil1 to vil, and i've been looking > >> for a way to get a vil_image_resource_sptr from a vil_image_view > >> (such that both refer to the same image data). is it possible to > >> perform such a 'conversion'? if so, what's the easiest way to do > >> so? > > Ian Scott replied: > > Use the vil_memory_image class. It is a vil_image_resource > > that stores its image data in memory. You could use a > > put_view to have them point to equivalent data. However, the > > code at present doesn't allow you to have them point to the same > > data. > > Does it make sense to try to get a vil_memory_image from a > vil_image_view in general? The whole point about a image_view is that > the data may not be contiguous, the steps may be negative, etc. A > single pointer to a location of memory will not capture the > information in the image_view except for a extremely restricted, > albeit common, set of views. Well currently, all a vil_memory_image does is provide an vil_image_resource API to a piece of image data that is held in memory. There is no currently no access to that data, and I am not aware of any reasons to provide it. To be honest, the only use of vil_memory_image that I can think of (and the reason it was written) was to test code that operated vil_image_resource, without having to worry about files. > Perhaps the solution is a vil implementation of > vgui_generic_image_view? I implemented this recently because I wanted > to store a view without storing the type. If you really want to do that there is already a good way of doing it - the vil_image_view_base_sptr. This is the type returned by vil_load, vil_image_resource::get_view, etc. The point at which you want to actual use the pixels (when you have to know their type) you can ask the view what type its pixels really are. > For the vgui case, I had to > do run-time type checks to convert to a pixel buffer anyway, so > "storing" the compile-time type information in the vil_image_view > without using member templates just lead to interface clutter. > > A vgui_generic_image_view stores all the information in a > vil_image_view: the steps, the base memory pointer, and pixel > format. It does not have compile time information. It is very much > designed for the limited use in vgui, but it could be extended to be > more general. I'm sorry I haven't paying attention to vgui, I could have suggested the above alternative much earlier. > > The biggest issue that arises is converting back to a vil_image_view > with compile time information. Perhaps extending (overloading) > vil_convert_cast to handle a generic view would do it. Otherwise, we > could add it to the list of acceptable arguments in the vil_image_view > constructor and operator=. I have been writing some additions (occasionally over the past two months) to vil_convert to force an vil_image_view_base_sptr into a known pixel type. These will look loosely like the existing vil_convert_to_grey_using_rgb_weighting() function, etc. However, there are a number of options about how to perform any such conversion. (e.g. Do you want raw casting, rounding, stretching to fit integer range, plane collapsing, etc?) and it has been non-trivial to find a API that combines simplicity, generality, and correctness. In light of your request, I will try to trounce these problems and commit a solution ASAP. Please bear in mind that Tim who is paying for this work cannot use a quick fix - I am writing this code in 2D images mostly as practice for the 3D medical image case where the issues of rounding, lots of int types, and range stretching are important to get correct. Ian. |