- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I want to convert a color image inside a standard TImage to a gray scale image. To do so, I wrote the following code in Delphi:
var
pSrc,PDst: PIpp8u;
DIB,FDIB,P: PIpp8u;
ScanLine:integer;
RoiSize:IppiSize;
begin
image1.Picture.LoadFromFile('test.bmp');
image1.Picture.Bitmap.PixelFormat:=pf24bit;
DIB := Image1.Picture.Bitmap.ScanLine[Image1.Picture.Bitmap.Height-1];
pSrc:=DIB;
FDIB := PIpp8u(Image1.Picture.Bitmap.ScanLine[Image1.Picture.Height-1]);
P := PIpp8u(Image1.Picture.Bitmap.ScanLine[Image1.Picture.Height-2]);
ScanLine := Integer(P) - Integer(FDIB);
RoiSize.width := Image1.Picture.Bitmap.Width;
RoiSize.height := Image1.Picture.Bitmap.Height;
PDst:=pSrc;
ippiRGBToGray_8u_C3C1R(pSrc,ScanLine,PDst,scanLine,RoiSize);
Image1.Refresh;
end;
But it doesnt' work correctly. Could you please tell me the wrong? Thanks , hadi.hadizadeh@gmail.com
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think my problem relates to the second scanline (for pDst) and also the pixel format of the output image in the following code:
ippiRGBToGray_8u_C3C1R(pSrc,ScanLine,PDst,scanLine,RoiSize);
In other words, How can I display the resulted gray image? Thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please take a look on IPP Delphi sample, which demostrate the basic for work with IPP on images under Delphi environment
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply. But I wrote the above code based on that Delphi sample. Unfortuately, I couldn't solve the problem. In fact, my question is that having a color image (3 channels) and by using ippiRGBToGray_8u_C3C1R the output image will have only one channel. Now, how can I display this output image by using a standard TImage componet directly without using any additional code (like canvas operations)? Do you have any idea to do so?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,hadipardis. I think you should use ippiDup_8u_C1C3R function. Before that you must allocate 1-chanell 8u image using ippiMalloc. Then in the ippiRGBToGray_8u_C3C1R you must put allocated 1-chanell 8u image as destination. And after That do
ippiDup_8u_C1C3R putting your Delphi's Tbitmap scanline as destination image. Allocated image works as temporary buffer. It will work. I've faced this problem. Hope it will help you a little.
ippiDup_8u_C1C3R putting your Delphi's Tbitmap scanline as destination image. Allocated image works as temporary buffer. It will work. I've faced this problem. Hope it will help you a little.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great!! Thank you very much for your help! Yes, this is the exact solution which I was looking for. It works very good. Thanks again cultzero!
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page