Image processing: Smart solution required to transform superincremental (128x128 pixels) coordinates

Cancer CT images are stored inside a short unsigned (1-dimensional) array.

I have information about the location of the area of ​​cancer inside the image, but the coordinates (x, y) are in superpixel (128x128 unsigned). My task is to highlight this region.

I have already solved this by converting the superpixel coordinates to an offset which I can use for an unsigned short array. It works great, but I am wondering if there is a smarter way to solve this problem since my solution requires 3 nested loops.

Is it possible to access the ushort array "superpixelwise" so I can navigate the ushort array in superpixels.

I know it doesn't work. To give you an idea of ​​what I was thinking:

typedef struct 
   unsigned short[128x128]

spix *spixptr;

unsigned short * bufptr = img->getBuf();

spixptr = bufptr;


Update 1:

Yes, its vague, let me try again with an image:

[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 128x128 at ushorts

once with a pointer, so I can memcpy

data in a 128x128 field.

Update 2:

The bitblit transfer assistant helped a lot.


source to share

2 answers

From what I understand you have:

  • Large image that is computed tomography
  • The rectangular area inside this image that is cancer

Then it gets a little harder to understand. I believe you want to create some kind of class so that you can efficiently use 128x128 image blocks as if they were one pixel.

So if the image was 1024x1024 pixels, you would need to access it as an 8x8 grid of 128x128 pixels. Now, if so, you need to create a class that represents one of these 128x128 blocks. This class should reference an image so that you don't copy the image data, and should contain all the operations you want to do on that "superpixel".

However, if all you want to do is extract the allocated 128x128 block from the larger image, then you need a bit blit . Transferring blocks of bits (commonly referred to simply as blits) will copy a selected bit of data from a larger image to a smaller one. The algorithm can also be adapted to do almost anything you want for a specific area in a large image.

If blit is all you want, every relatively modern graphics API should have blit functions.



Difficult to answer as it is rather vague.

If you only mean "how to access a pixel at (x, y) given this image definition", the answer shouldn't be very surprising:

typedef struct
    unsigned short data[128 * 128]; // This was broken in the question.
} spix;

void spix_set_pixel(spix *s, unsigned int x, unsigned int y, unsigned short value)
  s->data[y * 128 + x] = value;


Not sure if this answers your question, but it does sound ... believable, at least.



All Articles