-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Loading alternative additional pixel types (e.g. signed short) via ofPixels #3249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Additionally, if we don't add this to the core, then addons that implement custom FreeImage loading code probably need access to |
Also, just a note, I think this could result in a memory leak: Edit: PR here #3250 |
does it actually make sense to use signed ints for image data? |
Well, it's a possibility of the TIFF spec and they way they do it with GeoTIFF. For most purposes it probably doesn't make sense, but it does exist and FreeImage knows how to read it. openFrameworks just doesn't allow the possibility of using FreeImage in this way. It's certainly an edge case, and likely doesn't make sense in the context of an |
i think we only need to have support for 8bits, 16bits and 32bits, in ofImage. The fact that is signed or not shouldn't make any difference. Perhaps the load will be slightly slower because it needs a range conversion but it should work. Also when we load 16bits signed or unsigned in an 8bits ofImage it should do the conversion too. What i'm trying to say is that i don't think we need to give support for signed or unsigned, ust make the load methods convert from whatever format into the right one for the target ofPixels. the plan is to separate ofImage at some point into ofImageFile which will be able to read any type into any ofPixels_ but in any case i think having 8,16,32 ofImage versions should be enough, we just need to handle the conversion appropriately. so whenever we have ofImageFile we'll be able to do: imgFile >> signedShortPixels; but we'll still have only ofShortImage and that should work too |
That makes sense -- I think we just need to make a case for grayscale (1 channel) and the It fails here: The default (else) case, is invalid for the |
I modified some code in if(sizeof(PixelType)==1 &&
(FreeImage_GetColorType(bmp) == FIC_PALETTE || FreeImage_GetBPP(bmp) < 8
|| imgType!=FIT_BITMAP)) {
if(FreeImage_IsTransparent(bmp)) {
bmpConverted = FreeImage_ConvertTo32Bits(bmp);
////////////////////////////////////////////
// added this to support 16 bit grayscale images
} else if (FreeImage_GetBPP(bmp)==16) {
bmpConverted = FreeImage_ConvertToType(bmp,FIT_UINT16);
////////////////////////////////////////////
} else {
bmpConverted = FreeImage_ConvertTo24Bits(bmp);
}
bmp = bmpConverted; EDIT: It does not work as expected however. |
@bakercp : what tools did you use for reading geotiffs and the incorporated metadata? As far as I can see, there are no dedicated ofxAddons for geotiff. |
10 years after. ofPixels used to have an error with memory allocation, addressed recently on this PR
|
Hi all, I'm in the process of loading GeoTIFF images (terrain data from NASA, etc) and found that the images won't load in their native format using the standard
ofPixels
loading methods. After digging around a little bit, it turns out that it is because the image format (TIFF) uses 16bit signed shorts. I tried to then load it by passingofPixels_<short>
(as opposed to usingofShortPixels
(akaofPixels_<unsigned short>
), butputBmpIntoPixels()
method doesn't support signed short pixels and fails.Currently I'm able to successfully load the GeoTIFF images by reimplementing the FreeImage code, but I'm wondering if there would be a way to make
putBmpIntoPixels()
more flexible to allow data types other than the standardfloat
,unsigned char
, andunsigned short
when usingofPixels_<>
.I realize there are strategic and style reasons for pre-defining the
ofPixel_
types, but just curious. @arturoc do you have any thoughts on this?The text was updated successfully, but these errors were encountered: