A cancer CT picture is stored inside a unsigned short array (1-dimensional).
I have the location information of the cancer region inside the picture, but the coordinates (x,y) are in superpixel (128×128 unsigned short). My task is to highlight this region.
I already solved this one by converting superpixel coordinates into a offset a can use for the unsigned short array. It works fine but i wonder if there is a smarter way to solve this problem, since my solution needs 3 nested for-loops.
Is it possible to access the ushort array ‘superpixelwise’, so i can navigate the ushort array in superpixels.
I know this does not work. To give you an idea what I was thinking of:
typedef struct { unsigned short[128x128] } spix; spix *spixptr; unsigned short * bufptr = img->getBuf(); spixptr = bufptr;
Update 1:
Yep its vague, let me try again with a picture:
[0][1][2] ... [127]| ... [x] | [1] | | [2] | | . | | . | <-- this is a superpixel . | | [127] | | -------------------- | . | . | . | [y] |<--whole picture stored in a ushort* buf = new ushort[x*y] ------------------------------
I like to access the 128×128 ushorts at once with a pointer, so I can memcpy data into the 128×128 field.
Update 2:
The bitblit transfer hint helped a lot.
From what I understand you have:
Then it gets a bit harder to understand. I believe you want to create some sort of class so that you can effectively access 128×128 blocks of the image as if they were a single pixel.
So if the image was 1024×1024 pixels you’d want to be able to access it as a 8×8 grid of 128×128 pixel blocks. Now if this is the case what you need is to create a class that represents one of these 128×128 blocks. This class should reference the image, so that you don’t copy the image data, and should contain all of the operations that you’d want to do on that ‘superpixel’.
However if all you want to do is to be able to extract out a particular 128×128 block from the larger image then what you need is the bit blit algorithm. The bit block transfer (usually called just blit) will allow you to copy the selected bit of data from the larger image to a smaller one. The algorithm can also be adapted to do almost anything you want to a particular area in the larger image.
If a blit is all you need then every relatively modern graphics API should have blit function(s).