473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Changing 1/3 of a picture to different colour using python

I have some code so far, but I need it to only be applied to the bottom third of a photo, it is taking all the black spots in a photo and changing them to yellow. I just need it to only be applied to the bottom 1/3 of the photo. Here is the code I have right now:
Expand|Select|Wrap|Line Numbers
  1. def change(pic, startX, startY, getHeight, getWidth, endColour): 
  2.   width = getWidth
  3.   height = getHeight 
  4.   picture = makePicture(pic)
  5.   for px in getPixels(picture):
  6.     x = getX(px)
  7.     y = getY(px)
  8.     if (startX <= x <= getHeight) and (startY <= y <= getWidth):
  9.       if (distance(black, getColor(px)) < 95):
  10.         setColor(px, endColour)
  11.   show (picture)
  12.   return (picture)
[/python] [/pixels] [/color] [/forLoop]
Nov 3 '15 #1
2 1529
dwblas
626 Expert 512MB
You simply count the pixels as you process the picture, divide by 3, and make another pass, ignoring everything until the count hits the bottom third.
Nov 4 '15 #2
right, I am just not sure on how to incorporate that into my program.... I could get it to do the top third but that was as far as I got, and I need to top third to be untouched. With the middle third red and the bottom third yellow.
Nov 4 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sridhar R | last post by:
Hi, I am a little experienced python programmer (2 months). I am somewhat experienced in C/C++. I am planning (now in design stage) to write an IDE in python. The IDE will not be a simple...
2
by: Lois | last post by:
My website formatting knowledge is mostly HTML; I know hardly any Javascript. Recently I created a site with a nav bar in table format across the top of the page, and I made the background colour...
8
by: Joakim Persson | last post by:
Hello all. I am involved in a project where we have a desire to improve our software testing tools, and I'm in charge of looking for solutions regarding the logging of our software (originating...
27
by: hacker1017 | last post by:
im just asking out of curiosity.
8
by: John Salerno | last post by:
I figured my first step is to install the win32 extension, which I did, but I can't seem to find any documentation for it. A couple of the links on Mark Hammond's site don't seem to work. ...
5
by: kaisersose1995 | last post by:
Hi, I am trying to add some visual confirmation to a continous form, to let the user know if a stored date on the form has passed. I have managed to set the background colour using a simple IF...
3
by: gatoruss | last post by:
Newbie here with a (hopefully not) dumb question....tried searching around on the 'Net without success, so here goes.... I have been playing around with python. I wrote a script that sends an smtp...
1
by: Harika | last post by:
hi everybody Iam learning python. I have to write test scripts for c files. I did using swig and python. Using python i give input to a function and gets the output and shown using python script...
53
by: Vicent Giner | last post by:
Hello. I am new to Python. It seems a very interesting language to me. Its simplicity is very attractive. However, it is usually said that Python is not a compiled but interpreted programming...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.