0

How do I solve this, this is what I have done thus far. I am not a good programmer and don't understand this well. This is for an assignment.

Edit your gray scale function

The parameter is an image object
This function makes a gray scale image from the given image. Add a docstring to describe the function and its parameter
Write instructions similar to those in your negative function.
Within the body of the inner loop, call the median function (from myfunctions) with the red, green, and blue intensities of the current pixel to determine the intensities of the new pixel

code from myfunctions.py

def median(a1,a2,a3):
    ''''sorts and returns which value is median of a set'''
    if a1 > a2 and a1 < a3:
        return a1
    elif a2 > a1 and a2 < a3:
        return a2
    elif a2 > a3 and a2 < a1:
        return a2
    elif a3 > a2 and a3 < a1:
        return a3
    else:
        if a3 > a1 and a3 < a2:
            return a3

what i written thus far

def grayImage(g):
    '''this will produce a gray scale image from given image g'''
    import myfunctions
    newname = image.EmptyImage(g.getWidth(), g.getHeight())
    for row in range(g.getHeight()):
        for col in range(g.getWidth()):
            newimage = g.getPixel(col, row)
            x = myfunctions.median(newimage.getred(), newimage.getGreen(), newimage.getBlue())

            newred = 255 - newimage.getRed()
            newgreen = 255 - newimage.getGreen()
            newblue = 255 - newimage.getBlue()

            newpixel = image.Pixel(newred, newgreen, newblue)

            newname.setPixel(col, row, newpixel)

            return newname
halfer
  • 19,824
  • 17
  • 99
  • 186
Henry
  • 9
  • 1
  • 1
    `need to turn in assignment asap so really need help.` This isn't the best way to frame a question. Please look at how to provide a [mcve]. – cs95 Oct 30 '17 at 05:42
  • so what is the result produce and why do you need a median and I am sure someone wrote the grayscale function before already at least explain what you are trying to do the code is not enough for us to help you – Hamuel Oct 30 '17 at 05:42
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Oct 30 '17 at 10:36

0 Answers0