* * *

Author Topic: How can i convert multi color to Black and White ??  (Read 1912 times)

majid.ebru

  • Sr. Member
  • ****
  • Posts: 352
How can i convert multi color to Black and White ??
« on: October 14, 2017, 08:21:28 pm »
HI
How can i convert multi color to Black and White ?

in image down :
 how can i convert blue rang color to black&White rang color ??

thank you

lainz

  • Hero Member
  • *****
  • Posts: 2785
  • I'm coding :)
    • Lainz

BeanzMaster

  • Full Member
  • ***
  • Posts: 146
Re: How can i convert multi color to Black and White ??
« Reply #2 on: November 14, 2017, 02:59:25 pm »
Very simple

pseudo code :

Code: Pascal  [Select]
  1. Const
  2.   Thresold = 128;
  3.  
  4. For y:=0 to Img.Height-1
  5.   for  x:=0 to Img.Width -1
  6.   begin
  7.     Pixel := img.GetPixel(x,y);    
  8.     Intensity := (Pixel.Red+Pixel.Green+Pixel.Blue) div 3;
  9.     if intensity <  Thresold then newPixel:= clBlack else newPixel:= clWhite;
  10.     BWImg.PutPixel(x,y,NewPixel);
  11.  end;
  12.  

   

Thaddy

  • Hero Member
  • *****
  • Posts: 6368
Re: How can i convert multi color to Black and White ??
« Reply #3 on: November 14, 2017, 04:46:45 pm »
Very simple
It IS simple but not for gray scaling. And that was the question. First answer is correct.
I am enjoining wine, not whine....

BeanzMaster

  • Full Member
  • ***
  • Posts: 146
Re: How can i convert multi color to Black and White ??
« Reply #4 on: November 14, 2017, 10:02:08 pm »
The main question is 
Quote
How can i convert multi color to Black and White ??
not to grayscale

The 2nd is for grayscale
Quote
how can i convert blue rang color to black&White rang color ??

So by the way now they have the choice  :P
« Last Edit: November 14, 2017, 10:03:51 pm by BeanzMaster »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus