Note that there are some explanatory texts on larger screens.

plurals
  1. POimage processing
    primarykey
    data
    text
    <p>This is an assignment, i have put good effort since i am new to python programming:</p> <p>I am running the following function which takes in image and phrase (spaces will be removed so just text) as arguments, i have already been given all the import and preprocessing code, i just need to implement this function. I can only use getpixel, putpixel, load, and save. That is why coding this has been a hard task for me.</p> <pre><code>def InsertoImage(srcImage, phrase): pix = srcImage.load() for index,value in enumerate(phrase): pix[10+index,15] = phrase[index] srcImage.save() pass </code></pre> <p>This code is giving "system error" which says that "new style getargs format but argument is not tuple"</p> <p>Edit:</p> <pre><code>C:\Users\Nave\Desktop\a1&gt;a1_template.py lolmini.jpg Hi Traceback (most recent call last): File "C:\Users\Nave\Desktop\a1\a1_template.py", line 31, in &lt;module&gt; doLOLImage(srcImage, phrase) File "C:\Users\Nave\Desktop\a1\a1_template.py", line 23, in doLOLImage pix[10+index,15] = phrase[index] SystemError: new style getargs format but argument is not a tuple </code></pre> <p>Edit:</p> <p>Ok Thanks, i understood and now posting code but i am getting error for the if statement not sure why the if statement is not working, here is full code sorry for not adding it entirely before: </p> <p>from <strong>future</strong> import division </p> <h1>letters, numbers, and punctation are dictionaries mapping (uppercase)</h1> <h1>characters to Images representing that character</h1> <h1>NOTE: There is no space character stored!</h1> <p>from imageproc import letters, numbers, punctuation, preProcess </p> <h1>This is the function to implement</h1> <p>def InserttoImage(srcImage, phrase):<br> pix = srcImage.load()<br> for index,value in enumerate(phrase):<br> if value in letters:<br> pix[10+index, 15] = letters[value]<br> elif value in numbers:<br> pix[10+index, 15] = numbers[value]<br> elif value in punctuation: pix[10+index, 15] = punctuation[value]<br> srcImage.save()<br> pass </p> <h1>This code is performed when this script is called from the command line via:</h1> <h1>'python .py'</h1> <p>if <strong>name</strong> == '<strong>main</strong>':<br> srcImage, phrase = preProcess()<br> InserttoImage(srcImage, phrase) </p> <p>Thanks, letter, numbers, and punctuation are dictionaries which see the key element and open the image (font). But still there is an issue with pix[10+index, 15] as it is giving error:</p> <pre><code>pix[10+index, 15] = letters[value] </code></pre> <p>SystemError: new style getargs format but argument is not a tuple </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload