how to assign this value to y?
-
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
-
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
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.
-
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.
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
-
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
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" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>
-
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" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>
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
-
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
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; }
-
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
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" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>
-
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
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