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. how to assign this value to y?

how to assign this value to y?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
8 Posts 6 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.
  • G Offline
    G Offline
    gentleguy
    wrote on last edited by
    #1

    dear all i would like to convert RGB image to grayscale, however i couldn't, how to convert y = Rx0.3+Gx0.59+Bx0.11) below? int iWidth=m_vicImg.endx-m_vicImg.stx+1; int iHeight=m_vicImg.endy-m_vicImg.sty+1; int iBuffwidth=m_vicImg.buffwidth; unsigned char *ucImgdata=m_vicImg.ibuff; for(int iY=0;iY { for(int iX=0;iX { ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]); } ucImgdata+=iBuffwidth; } error C2440: '=' : cannot convert from 'double' to 'unsigned char *' i know ucImgdata type is different with what we signed in left, but i can't do correctly. anyone help me, thanks

    Li Zhiyuan

    R U D 3 Replies Last reply
    0
    • G gentleguy

      dear all i would like to convert RGB image to grayscale, however i couldn't, how to convert y = Rx0.3+Gx0.59+Bx0.11) below? int iWidth=m_vicImg.endx-m_vicImg.stx+1; int iHeight=m_vicImg.endy-m_vicImg.sty+1; int iBuffwidth=m_vicImg.buffwidth; unsigned char *ucImgdata=m_vicImg.ibuff; for(int iY=0;iY { for(int iX=0;iX { ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]); } ucImgdata+=iBuffwidth; } error C2440: '=' : cannot convert from 'double' to 'unsigned char *' i know ucImgdata type is different with what we signed in left, but i can't do correctly. anyone help me, thanks

      Li Zhiyuan

      R Offline
      R Offline
      Rajkumar R
      wrote on last edited by
      #2

      li zhiyuan wrote:

      ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]); error C2440: '=' : cannot convert from 'double' to 'unsigned char *'

      may be the following useful, ucImgdata[iX+2] = ucImgdata[iX+1] = ucImgdata[iX] =(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]); but i think the current available code is not written yourself. you need to be familiar with basic array, pointer concepts.

      M 1 Reply Last reply
      0
      • R Rajkumar R

        li zhiyuan wrote:

        ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]); error C2440: '=' : cannot convert from 'double' to 'unsigned char *'

        may be the following useful, ucImgdata[iX+2] = ucImgdata[iX+1] = ucImgdata[iX] =(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]); but i think the current available code is not written yourself. you need to be familiar with basic array, pointer concepts.

        M Offline
        M Offline
        Maxwell Chen
        wrote on last edited by
        #3

        Rajkumar R wrote:

        but i think the current available code is not written yourself. you need to be familiar with basic array, pointer concepts.

        People here keep telling him this, but he just doesn't listen ... X|

        Maxwell Chen

        T 1 Reply Last reply
        0
        • M Maxwell Chen

          Rajkumar R wrote:

          but i think the current available code is not written yourself. you need to be familiar with basic array, pointer concepts.

          People here keep telling him this, but he just doesn't listen ... X|

          Maxwell Chen

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          Maxwell Chen wrote:

          People here keep telling him this, but he just doesn't listen ...

          Right you say...!but could we try to find why yuo he don't want to listen.. any language problem, since by name he seems to no english speaking country!

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
          Never mind - my own stupidity is the source of every "problem" - Mixture

          cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

          M 1 Reply Last reply
          0
          • T ThatsAlok

            Maxwell Chen wrote:

            People here keep telling him this, but he just doesn't listen ...

            Right you say...!but could we try to find why yuo he don't want to listen.. any language problem, since by name he seems to no english speaking country!

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
            Never mind - my own stupidity is the source of every "problem" - Mixture

            cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

            M Offline
            M Offline
            Maxwell Chen
            wrote on last edited by
            #5

            ThatsAlok wrote:

            but could we try to find why yuo he don't want to listen.. any language problem, since by name he seems to no english speaking country!

            If I recall correctly, "li zhiyuan" is from China and now lives in Malaysia.

            Maxwell Chen

            T 1 Reply Last reply
            0
            • G gentleguy

              dear all i would like to convert RGB image to grayscale, however i couldn't, how to convert y = Rx0.3+Gx0.59+Bx0.11) below? int iWidth=m_vicImg.endx-m_vicImg.stx+1; int iHeight=m_vicImg.endy-m_vicImg.sty+1; int iBuffwidth=m_vicImg.buffwidth; unsigned char *ucImgdata=m_vicImg.ibuff; for(int iY=0;iY { for(int iX=0;iX { ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]); } ucImgdata+=iBuffwidth; } error C2440: '=' : cannot convert from 'double' to 'unsigned char *' i know ucImgdata type is different with what we signed in left, but i can't do correctly. anyone help me, thanks

              Li Zhiyuan

              U Offline
              U Offline
              uusheikh
              wrote on last edited by
              #6

              You code still doesnt look correct enough. In image processing, normally we write in this way; x_start,y_start, x_end, y_end are the coordinates for your ROI (Region of Interest) Also note, the RGB image is 24-bit (hence the 3 = 24/8). Array indexing is used as x*depth + y *depth*image width (not region width) Also note, on IA-x86 (Intel Arch), RGB in memory comes as BGR for(int y = y_start; y < y_end; y++) for(int x = x_start; x < x_end; x++) { pImageGray[x+y*width] = pImageRGB[x*3 + y*width*3 + 0]*0.112 + pImageRGB[x*3 + y*width*3 + 1]*0.59 + pImageRGB[x*3 + y*width*3 + 2]*0.33; }

              1 Reply Last reply
              0
              • M Maxwell Chen

                ThatsAlok wrote:

                but could we try to find why yuo he don't want to listen.. any language problem, since by name he seems to no english speaking country!

                If I recall correctly, "li zhiyuan" is from China and now lives in Malaysia.

                Maxwell Chen

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                ohh great! ;-)

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                Never mind - my own stupidity is the source of every "problem" - Mixture

                cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

                1 Reply Last reply
                0
                • G gentleguy

                  dear all i would like to convert RGB image to grayscale, however i couldn't, how to convert y = Rx0.3+Gx0.59+Bx0.11) below? int iWidth=m_vicImg.endx-m_vicImg.stx+1; int iHeight=m_vicImg.endy-m_vicImg.sty+1; int iBuffwidth=m_vicImg.buffwidth; unsigned char *ucImgdata=m_vicImg.ibuff; for(int iY=0;iY { for(int iX=0;iX { ucImgdata=(0.3*ucImgdata[iX+2] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX]); } ucImgdata+=iBuffwidth; } error C2440: '=' : cannot convert from 'double' to 'unsigned char *' i know ucImgdata type is different with what we signed in left, but i can't do correctly. anyone help me, thanks

                  Li Zhiyuan

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  li zhiyuan wrote:

                  error C2440: '=' : cannot convert from 'double' to 'unsigned char *'

                  See here.

                  "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  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