This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint16_t pix = 0; | |
uint16_t min = 34464; | |
uint16_t max = 0; | |
uint16_t *d = (uint16_t*) imgData; | |
for (int i = 0; i < 512 * 512; i++) { | |
pix = d[i]; | |
if (pix > max) | |
max = pix; | |
else if (pix < min) | |
min = pix; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint16_t pix; | |
uint16_t min = 34464; | |
uint16_t max = 0; | |
uint16_t *d = (uint16_t*) imgData; | |
for (int i = 0; i < 512 * 512; i++) { | |
pix = d[i]; | |
if (pix > max) | |
max = pix; | |
else if (pix < min) | |
min = pix; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGDataProviderRef provider = CGDataProviderCreateWithCFData((__bridge CFDataRef) data); | |
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray(); | |
CGImageRef img = CGImageCreate(width, height, bits_allocated, bits_allocated, | |
width,// * (bits_allocated / 8), | |
colorspace, | |
kCGBitmapByteOrderDefault, | |
provider, NULL, YES, | |
kCGRenderingIntentDefault | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In the interface: | |
@interface TransferFunction : NSObject { | |
id <TransferFunctionDrawingDelegate> _delegate; | |
} | |
@property (nonatomic, weak) id <TransferFunctionDrawingDelegate> delegate; | |
// In the implementation: | |
@synthesize delegate=setDelegate; | |
- (void)setDelegate:(id <TransferFunctionDrawingDelegate>)delegate { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint16_t *remapped = (uint16_t*) malloc(width * height * sizeof(uint16_t)); | |
vImage_Buffer src = {imgData, | |
(vImagePixelCount) height, | |
(vImagePixelCount) width, | |
bytes_per_row | |
}; | |
vImage_Buffer dst = {remapped, | |
(vImagePixelCount) height, | |
(vImagePixelCount) width, | |
bytes_per_row |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableArray *histo = [NSMutableArray array]; | |
for (int i = 0; i < num_bins; i++) | |
[histo insertObject:[NSNumber numberWithUnsignedLong:histogram[i]] atIndex:i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8 *fourchan = (uint8*) malloc(sizeof(uint8) * width * height * 4); | |
short cur; | |
short *subscript = (short*) imgData; | |
for (int i = 0; i < width * height; i++) { | |
cur = (subscript[i] + 1000) / (int) pow(2., sizeof(short)/2.); | |
fourchan[i*4] = (uint8) cur; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8 *fourchan = (uint8*) malloc(sizeof(uint8) * width * height * 4); | |
short cur; | |
short *subscript = (short*) imgData; | |
for (int i = 0; i < width * height; i++) { | |
cur = subscript[i] + 1000; | |
fourchan[i*4] = cur; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// works: | |
return [TransferFunctionPoint pointWithX:x | |
Y:intercol.w | |
Color:[UIColor greenColor]]; | |
// runtime error: | |
return [TransferFunctionPoint pointWithX:x | |
Y:intercol.w | |
Color:[UIColor colorWithRed:1. green:1. blue:0. alpha:1.]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (TransferFunctionPoint *)pointWithX:(double)_x Y:(double)_y Color:(UIColor*)_color { | |
TransferFunctionPoint *p = [[[self class] alloc] init]; | |
p.x = _x; | |
p.y = _y; | |
p.color = _color; | |
return p; | |
} |