|
sorry dude,
as Cpallini told, its better to understand from good OOPs book, search the web, if u have doubt, after that post ur queries, lot of gurus are there in CP to help u out.
say i got a article on webcplusplus.com[^]
|
|
|
|
|
rowdy_vc++ wrote: any body plz explain..
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
|
|
|
|
|
dear all
howt to convert color image to grayscale image in c++? anyone has such code? thanks a lot
Li Zhiyuan
|
|
|
|
|
There are several articles on codeproject about turning RGB colours into HSL (hue, saturation, luminence) colours - and to get grey scale, you can just extract the luminence component for your needs.
Or search for rgb and grayscale on codeproject for some other mentions of your problem;
http://www.google.com/search?hl=en&q=rgb+grayscale+%2Bsite%3Acodeproject.com&btnG=Search[^]
(Some people may spell it greyscale too.
Good luck,
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Can't you simply average the color components, i.e.
COLORREF color, gray;
BYTE avg = (GetRValue(color) + GetGValue(color) + GetBValue(color))/3;
gray = RGB(avg, avg, avg);
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
then (R = 100, G = 0, B = 0) and (R= 0, G =100, B = 0) and (R=0, g= 0, b= 100) all gives the same value, that is if the image has 3 region each filled with Red, Green, Blue respectively, then the whole image has same gray value (can't identify the regions)
modified on Thursday, February 21, 2008 5:06 AM
|
|
|
|
|
Color to Gray space conversion is lossy by definition:
RGB Color space allows 2^24 different values for color image pixels, while the constraint RGB(x,x,x) implies 2^8 different values for gray pixels. Thus we have a mapping of a 2^24 set to 2^8 set, i.e. a lossy mapping.
Average is a very simple method to obtain a grayscale image, maybe also a naive (though working) one, but the lossy nature of the conversion is unavoidable.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I know that.
but averaging u meantion cannot differentiate even very distinct colours RED, GREEN, BLUE. I personally don't believe that averaging is a solution. eventhough the actual solution is some sort of weighted average
modified on Thursday, February 21, 2008 5:52 AM
|
|
|
|
|
Rajkumar R wrote: but averaging u meantion cannot differentiate even very distinct colours RED, GREEN, BLUE.
The above is obviously true.
Rajkumar R wrote: I personally don't believe averaging is a solution.
You're wrong. It is a quite acceptable solution, because (as I've already written) is a function mapping the color space set to the the grayspace one. It is also a reasonable mapping. Of course there are many possible solutions and the better one maybe application-dependent.
Now a simple question: are you able to distinguish a full red from a full green in a B/W movie? Does it matter to the Director?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
CPallini wrote: distinguish a full red from a full green in a B/W movie? Does it matter to the Director?
lol !!! , instead he can put black screen, save light energy.
|
|
|
|
|
thanks all friends
how to blur or mask a color image, actually i load a jpeg image to computer, now i would like to smooth via Gaussion function, but one of friend said i have to convert color image to grayscale image and then i can blur, so now i don't how to do? anyone has such code or suggestion? thanks a lot
Li Zhiyuan
|
|
|
|
|
|
search for "MakeInactiveDemo" in codeproject he has a function to convert image to grayscale
|
|
|
|
|
thanks friend
anyone know how to convolution of image? i have a little problem of concept, how to multiply two arrays? and how to put new value in new array, thanks a lot, urgent
Li Zhiyuan
|
|
|
|
|
dear all
how to solve the following problem? thanks a lot.
int value1[3][3]={{-1,0,1},{-1,0,1},{-1,0,1}};
int value2[3][3]={{-1,-1,-1},{0,0,0},{1,1,1}};
int Mask[3][3];
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;
int *ucImgdata1 ;
for(int iY=0;iY<iHeight;iY++)
{
for(int iX=0;iX<iWidth*3;iX+=3)
{
ucImgdata1 = 0.3*ucImgdata[iX] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX+2];
}
ucImgdata+=iBuffwidth;
}
the error is below:
error C2440: '=' : cannot convert from 'int' to 'int *'
Li Zhiyuan
modified on Thursday, February 21, 2008 3:20 AM
|
|
|
|
|
Actually the error is
error C2440: '=' : cannot convert from 'double' to 'int *'
and it is pretty explanatory: the right side of the assignment, i.e.
0.3*ucImgdata[iX] + 0.59*ucImgdata[iX+1] + 0.11*ucImgdata[iX+2]
is an expression that evaluates to a double , while the left side (the l-value), i.e.
ucImgdata1
is declared as int * .
Such assignment is simply a mistake and I cannot understand what you intend to do with such code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hai Friends,
I am in need to change the height of the drop down list
of a combo box.
When a combo box is clicked, it shows only the first 8 items
and remaining items can be scrolled to view.
How to increase the height of this drop down list to
view the desired number of combo items.
I tried using MoveWindow API
<br />
int ListHeight;<br />
ListHeight=SendMessage(Combo.hWnd,CB_GETITEMHEIGHT,0, 0);<br />
ListHeight=ListHeight*(Combo.GetCount());<br />
MoveWindow(Combo.hWnd,Combo.Left,Combo.Top,Combo.Width,ListHeight,1);<br />
But does not work as we wish.
Thanks for your help.
|
|
|
|
|
combo box contains 3 windows, combo, edit, list.
u have to change the height of list, in ur code u r trying to change the height of combo box.
u can change the height in resource editor,
if u want to change the height programmatically, try setting the size to list window, the handle to list box can be obtained from, CB_GETCOMBOBOXINFO message.
|
|
|
|
|
1/ In the resource editor, click on the drop down arrow for the combo box - this will give an outline of the drop down box, and you can change that
2/ Try using CM_SETMINVISIBLE - I've not used this, but it looks useful.
3/ Alternatively, use CB_GETCOMBOBOXINFO to fill in a COMBOBOXINFO structure (don;t forget to fill in it's cbSize first). This will give you the window handle to the List control it uses for the drop down part. You can then use
SetWindowPos (NULL, 0,0, cx,cy, SWP_NOMOVE | SWP_NOZORDER); to change the size.
I hope that's given you enough ammunition!
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
poda wrote: How to increase the height of this drop down list to
view the desired number of combo items.
Employ a smarter combobox.
"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
|
|
|
|
|
Thanks for you replys friends.
But CB_GETCOMBOBOXINFO is undefined in my system.
What SDK should I install to get it work.
Please give me the link to update my SDK.
The winuser.h header does not have such #define.
My system is WinXP with SP2 and SDK is March 2006 Release.
|
|
|
|
|
#if(_WIN32_WINNT >= 0x0501)
#define CB_GETCOMBOBOXINFO 0x0164
#endif /* _WIN32_WINNT >= 0x0501 */
is defined like above in winuer.h. define _WIN32_WINNT >= 0x0501.
if not found install the latest SDK.
|
|
|
|
|
Hi All
How can i get the Cursor(Which pointer is used like Pointer or Hand or Help ect) of the Mouse?
Any help will be highly appriceated.
Thanks in advance
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
I have HCURSOR handle using GetCursorInfo function.
now how can i extract information of mouse icon from this handle?
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Do you want to set the Mouse Cursor in your application to hand/hourglass etc? See SetCursor with IDC_HAND etc
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|