LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-10-2015, 11:51 AM   #1
linux_beginner
LQ Newbie
 
Registered: Mar 2006
Posts: 7

Rep: Reputation: 0
Custom monochrome image conversion


Hey all,

I would like to do a custom monochrome conversion of any color image using a script. All colors except those in a narrow range are to be converted to white, and the colors within said narrow range are to be converted to black.

I've attached a sample picture to this post; the objective is to basically get a black dot in a white background (the black dot coming from the red dot).

Any advice on how to go about this?

Also, which is the best file format for quick image scanning/manipulations/conversions and maintenance of sharp edges? PNG?

Cheers.
Attached Thumbnails
Click image for larger version

Name:	nature_dot.jpg
Views:	46
Size:	95.7 KB
ID:	18068  
 
Old 04-10-2015, 12:15 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
For image manipulations you should use a format without compression, like BMP. Commandline tools for image editing and conversion are avilable, for example the ImageMagick tools, which should be available for amy distro. I am not experienced with those, but it should be possible to use them for your purpose.
I hope that helps a bit.
 
Old 04-10-2015, 12:37 PM   #3
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
All colors except those in a narrow range are to be converted to white, and the colors within said narrow range are to be converted to black.
And what would those in the "narrow range" be converted to?
 
Old 04-10-2015, 12:40 PM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,885
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
I'd like to know if there's something comprehensive too. I'm familiar with Photoshop and GIMP and both allow the bucket fill to "fill by color" however they both tend to find boundaries in shading, lines, or other things where the stop. Like I took a picture of Mt. Everest and tried to convert it using that technique and ... you'd be amazed how many shades of white ice/snow there are. Or they are interrupted by lines of some type. Hence you click and it fills some, but nowhere near enough.

Next, I am familiar with algorithms, unfortunately proprietary stuff where they scan line by line and filter, plus convert. So via a program, I'd follow those same procedures, which would be to load a line of pixels in an array, or rather load the whole picture if needed, then process the whole thing like a serial buffer, just [0][0] to [n][m] and convert based on a choice like > 50% = black, else = white.
 
Old 04-10-2015, 09:14 PM   #5
linux_beginner
LQ Newbie
 
Registered: Mar 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Hey all,

I found out how to do it.

http://www.fmwconcepts.com/imagemagi...lors/index.php

In bash, type:
locatecolors -b "rgb(245,0,0)" -e "rgb(255,0,0)" -m and nature_dot.png out.png

The script doesn't work with jpgs, so you have to convert it first.
convert nature_dot.jpg nature_dot.png

Cheers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
image conversion reza_zah1991 Programming 4 11-02-2013 04:45 PM
3D image conversion software? OneManOfBits Linux - Software 4 09-23-2008 09:29 AM
ghostcast image file conversion supradrvr Linux - General 0 09-23-2007 10:27 AM
Custom kernel image on custom slack build using CUSS nykey Slackware 2 07-15-2006 03:05 AM
Batch image conversion mrsolo Linux - Software 1 09-06-2004 04:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration