Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. dividing image into blocks

dividing image into blocks

Scheduled Pinned Locked Moved C / C++ / MFC
c++performance
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mareo_421
    wrote on last edited by
    #1

    I am new in c++, can Anybody tell me how one can divide image into blocks. I have yuv format image saved in byte memory. I want to divide it into 16x 16 blocks The image size is 144x176. I want to process further each block for calculating motion estimation . Thanks koreno

    C _ 2 Replies Last reply
    0
    • M Mareo_421

      I am new in c++, can Anybody tell me how one can divide image into blocks. I have yuv format image saved in byte memory. I want to divide it into 16x 16 blocks The image size is 144x176. I want to process further each block for calculating motion estimation . Thanks koreno

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Seeing as it's in a non-Windows format, I assume you have a bunch of raw pixel data. Surely, you just need to create 16x16 blocks of memory ( well, 48x16 ) and copy the data across ? Christian Graus - Microsoft MVP - C++

      M 1 Reply Last reply
      0
      • C Christian Graus

        Seeing as it's in a non-Windows format, I assume you have a bunch of raw pixel data. Surely, you just need to create 16x16 blocks of memory ( well, 48x16 ) and copy the data across ? Christian Graus - Microsoft MVP - C++

        M Offline
        M Offline
        Mareo_421
        wrote on last edited by
        #3

        I have a video sequence foreman.yuv.I can read frame separately, But my questions is still there , The data is in byte memory in an array, while i need a 16x16 block in raster form . I know it is not difficult question but I could have idea how i will use loop to acquire the refereces to each block in the image . koreno

        C 1 Reply Last reply
        0
        • M Mareo_421

          I have a video sequence foreman.yuv.I can read frame separately, But my questions is still there , The data is in byte memory in an array, while i need a 16x16 block in raster form . I know it is not difficult question but I could have idea how i will use loop to acquire the refereces to each block in the image . koreno

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          What do you mean by 'in raster form' ? Do you need it to be RGB ? I'm not sure what the overall format is here, but YUV is still a format where one triple is a pixel, right ? So, you just need to copy out the triples for the pixels you want. Which means working in blocks of 48, and then working out the number of bytes in a row in order to jump by rows. Christian Graus - Microsoft MVP - C++

          1 Reply Last reply
          0
          • M Mareo_421

            I am new in c++, can Anybody tell me how one can divide image into blocks. I have yuv format image saved in byte memory. I want to divide it into 16x 16 blocks The image size is 144x176. I want to process further each block for calculating motion estimation . Thanks koreno

            _ Offline
            _ Offline
            __yb
            wrote on last edited by
            #5

            this should be no problem if u know it's data format. I don't know what format u are reffering to, so lets assume the pixels are arranged in lines and are 4 bytes. Now u can just read the blocks in a double loop:

            int bx = block_x*block_width;
            int by = block_y*block_height;
            for(int x=0; x<16; x++) {
            for(int y=0; y<16; y++) {
            int pixel = data[(y+by)*img_width+(x+bx)];
            }
            }

            HTH, :-)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups