Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Striped Image problem

  1. #1

    Striped Image problem

    Hi,

    I trying a simple gray scale to image but the result is a striped image( applying voluntarily at the bottom only ):



    Kernel :

    Code :
    	"__kernel void copy(__read_only image2d_t imageIn,__write_only image2d_t imageOut)",
    	"{",
    		"const sampler_t sampler=CLK_NORMALIZED_COORDS_FALSE|CLK_ADDRESS_CLAMP|CLK_FILTER_NEAREST;",
    		"int gid0 = get_global_id(0);",
    		"int gid1 = get_global_id(1);",
    		"uint4 pixel;",
     
    		"pixel=read_imageui(imageIn,sampler,(int2)(gid0,gid1));",
     
    		"if(gid1 < 50 )",
    		"{",
    			"pixel = (uint4)(0.299*pixel.x + 0.587*pixel.y + 0.114*pixel.z);",
    //			"pixel = (uint4)(0.6*pixel.x + 0.3*pixel.y + 0.1*pixel.z);",
    //			"pixel = (uint4)pixel/2;",
     
    		"}",
    		"write_imageui(imageOut,(int2)(gid0,gid1),pixel);",
    	"}",

    when I have :


    pixel = (uint4)pixel/2; //work

    -> I can see that :
    pixel.xyz = pixel.xyz / 2

    idem for :
    pixel = (uint4)((pixel.x + pixel.y + pixel.z)/3) //work



    pixel = (uint4)(0.6*pixel.x + 0.3*pixel.y + 0.1*pixel.z) //don't work correctly, striped

    So, is somebody had the same problem, and how can I resolve it?
    What I'm really want is understand how it works.

    Thanks.

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Striped Image problem

    I am puzzled as well

    Could this have something to do with using integer coefficients vs. using floats? In your examples, using integers always works and using floats always fails, so I wonder if there are some weird type promotion rules at work.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3

    Re: Striped Image problem

    I hope for my career that it's not only a cast problem.
    Excuse my lack of knowledge.

    I just tried :
    Code :
    pixel = (uint4)((0.3*pixel.x + 0.3*pixel.y + 0.3*pixel.z)/0.9);
    , and grayscale works well, but for exemple :
    Code :
    pixel = (uint4)((0.4*pixel.x + 0.3*pixel.y + 0.2*pixel.z)/0.9);
    is striped.

    I tried to work with float4 pixel, read_imagef(...) , but kernel is not executed.

    It's seems like pixel.x, pixel.y, pixel.z is columns of image.

    Am I wrong?

  4. #4

    Re: Striped Image problem

    (Can't edit previous post)

    P.S. : Also see :
    http://www.khronos.org/message_board...hp?f=37&t=2495
    , but it's not really the solution to convert to 32bpp, and I tried but have problem to save image to 32bpp with gimp.

  5. #5
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Striped Image problem

    I feel like I'm missing something obvious...

    Anyway, have you tried this?

    Code :
    pixel = (uint4)((4*pixel.x + 3*pixel.y + 2*pixel.z)/9);

    What about this?

    Code :
    pixel = (4*pixel.x + 3*pixel.y + 2*pixel.z)/9;
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  6. #6

    Re: Striped Image problem

    Both codes give the same result (with (4,3,2) coefficients , and not (0.4,0.3,0.2)) :



    P.S. : I haven't debugger for kernel, but i can test it by changing "if" condition
    if(gid < 50){...} <-> if(gid < 100){...} //height of gray part

  7. #7
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Striped Image problem

    That gave me an idea. How did you allocate the image? Please show us the call to clCreateImage2D().
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  8. #8
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Striped Image problem

    BTW, did you read the solution to the thread you linked to? The source image was in RGB888 format and they were reading it as RGBA8888. That sounds like the same problem you are seeing here -- I knew I was missing something obvious.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  9. #9

    Re: Striped Image problem

    Call to clCreateImage2D() :
    Code :
    	cl_image_format format;
    	format.image_channel_order = CL_RGBA;
    	format.image_channel_data_type = CL_UNSIGNED_INT8;
     
    	cl_mem imagea = clCreateImage2D (	context,
    										CL_MEM_READ_ONLY ,
    										&format,
    										width,
    										height,
    										rowpitch,
    										0,
    										&error);

    If passing from 24bpp to 32bpp solves the problem, this should be RGBA. What I meant was that conversion shouldn't be the solution, unless there is no choice, of course...or maybe work with other format?

  10. #10
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Striped Image problem

    I don't understand. What's the problem with converting from RGB to RGBA? It's a simple transformation. OpenCL doesn't support RGB888.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Page 1 of 2 12 LastLast

Similar Threads

  1. Image editing problem
    By jabak in forum OpenCL
    Replies: 3
    Last Post: 10-09-2012, 12:59 AM
  2. Problem with normalized image coordinates
    By ffelagund in forum OpenCL
    Replies: 7
    Last Post: 12-01-2011, 05:52 PM
  3. Strange problem wirting to image
    By icepic1984 in forum OpenCL
    Replies: 5
    Last Post: 11-20-2011, 09:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •