Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Getting the green pixels of a picture. HELP REQUIRED IF POSSIBLE Posted by fingerknight on 20 Jun 2003 at 6:50 AM
hi. i have problem in which i need to Scan the image and retrieve the Green part of every pixel. Convert the result to ascii symbols. but i have no idea how to even start can someone help plzzzzzzzzzzz
Report
Re: Getting the green pixels of a picture. HELP REQUIRED IF POSSIBLE Posted by zibadian on 20 Jun 2003 at 10:59 AM
: hi. i have problem in which i need to Scan the image and retrieve the Green part of every pixel. Convert the result to ascii symbols. but i have no idea how to even start can someone help plzzzzzzzzzzz
:
Depending on the colordepth, this can be quite simple. If the colordepth is 24 then each pixel is coded using the RGB-method. This means that the first three bytes are red-green-blue. The fourth is usually not used, but can indicate a system color.
Other commonly used methods include using a palette of colors. All you need to do then is build a reference table of the greens based on the palette, and then use that table to read the pixels.
As for scanning the image, this might be can be best done using a bitmap. So the first part is to get the image's bitmap, which can be quite easy (a windows bitmap) or quite difficult (a jpeg). I don't have any source codes on these things, so I cannot help you with that.
Once you got the bitmap, it is usually given in a 2D-array, which you can easily scan using 2 for-do loops to get to each pixel.
The conversion to ascii symbols can be easily done by type-casting or by using a reference string. Examples:
var
  PixelGreen: byte;
  AsciiCode: char;
begin
  ...
  AsciiCode := char(PixelGreen);
  ...
end;

const
  HexDec: string = '0123465789ABCDEF';
  PixelGreen: byte;
  AsciiCode: char;
begin
  ...
  AsciiCode := HexDec[PixelGreen+1]; { +1 because a string is 1-indexed }
  ...
end;

I hope this gives you a place to start.
Report
Re: Getting the green pixels of a picture. No Problem... Posted by Phat Nat on 22 Jun 2003 at 3:14 AM
: hi. i have problem in which i need to Scan the image and retrieve the Green part of every pixel. Convert the result to ascii symbols. but i have no idea how to even start can someone help plzzzzzzzzzzz
:

Are you trying to convert a picture to ASCII art using just the green channel? Explain what you want it for and we can help out a little more.

The problem with converting just the greens, is just what is "green". Will this include Bluish-green or Yellow-Green (Puke green)? Where do you decipher between Green & yellow or blue or brown?

If you want strictly the Green Channel, then that is simple. For 24-bit pics, just use the green level byte; for 16-bit pics, just use the 5-bit (I think) green level; 8-Bit/256 Color, just get the number corresponding to the color and then get the 6-bit color level of green (0-63)

For strictly green pixels, just use the method above, but only accept it if the Red & Blue values are zero.

Leave a message if you need more help. (Conversion/Get Color Levels/Data Formats/etc)

Phat Nat




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.