Convert raw image into mosaic-image representation

asked 2016-02-23 09:09:27 -0500

Syafiq gravatar image

Hi, this is my first time using opencv and i'm beginner in C++. what i want to:

  1. Read an image.
  2. Convert image into tiles image.
  3. Read color value on each tile.

almost like figure below.

image description

I have through forum and i found out a few way that maybe can be use to do this. It is possible to split image into block first or using kernel and convolution concept to convert image into mosaic-represantation. or there is other way/function that is more direct and simple?

edit retag flag offensive close merge delete



I don't know if it is for you school project or not but that's a funny project. About read image read docs and look on github. you can try this sample

After you can resize your image without interpolation to result size and look for nearest color in your tile images.

LBerger gravatar imageLBerger ( 2016-02-23 09:50:58 -0500 )edit

Ok, so you found a few ways to go...Why not implement them, see the time it takes each one and then come back if you are not pleased with it and ask for help? What I find a little hard is to do the thing of not having the same tile one next to another

thdrksdfthmn gravatar imagethdrksdfthmn ( 2016-02-23 09:58:03 -0500 )edit

take a look at this post

sturkmen gravatar imagesturkmen ( 2016-02-23 10:07:07 -0500 )edit

yeah @LBerger..actually this is my school project..

@sturkmen thanks...that actually output that i want...but actually i also need to reduce a pixel number such as every group of pixel is compress to become a pixel(tile) because my project use this image output for robot arm pick and place actual tile to become exactly like the image..then i think i need to go through each pixel through it's column follow by it's row and read and average pixel value one by one by using<uchar>(Point(x,y)). But i have problem when i test to set value on pixel of image by using this code

for (int x = 0; x < img.cols; x++){
    for (int y = 0; y < img.rows; y++){<uchar>(Point(x, y)) = 255;
Syafiq gravatar imageSyafiq ( 2016-03-09 21:26:34 -0500 )edit

i have image test of 600x600 pixel..I was expecting it to cover the entire image in white, but unfortunately is not. right side image is not cover by white.

can somebody help me with this problem...i thought my loop is correct but i dont know why the output like that.i already stuck at my first step.. so how i can modify my code so the<char> can read all pixel in image through column and follow by row.?

Syafiq gravatar imageSyafiq ( 2016-03-09 21:28:07 -0500 )edit

It seem that i need to times 3 on img.col to make entire image is white

for (int x = 0; x < (img.cols*3); x++){
        for (int y = 0; y < img.rows; y++){
  <uchar>(Point(x, y)) = 255;

why it should be like that..can someone give me clear explanation about this issue??

Syafiq gravatar imageSyafiq ( 2016-03-09 21:58:15 -0500 )edit