Main thread
It's called pillow over there - it's an improved PIL.
Apparently, we were supposed to (using our well known ability to read minds) download these missing modules through some obscure link. Said link shows up in a .py file from the last recitation with Amir, who teaches only part of the students. This link (surprise surprise) does not show up anywhere is the logs of the other recitation. What a shame for those who missed class, maybe dozed off for a moment during an inopportune time or simply forgot.
So for those who are wondering, get it from the link in the file called: 'images.py' under the recitations logs for Amirs group. I would post it myself but apparently my "karma" is too low.
Here is the link:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Search for PILLOW and download a version that is suitable for you operating system (AMD64 or WIN32, choose 32 if you are not sure) and python version (most likely python 3.2 if you installed it like we suggested at the beginning of the course).
For the previous commenter - thanks for explaining the solution, but please try to maintain a pleasant atmosphere in this forum. We never intend to waste your time or to cause you any grieve, so expressions like "surprise surprise" and "read minds" are not helpful and are actually hurtful.
As a rule, if you don't want to sign your name on a comment then maybe you shouldn't post it as it is.
Sorry for any inconvenience.
did you try-
sudo apt-get install python3-dev python3-setuptools
sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms1-dev libwebp-dev
and then pip install pillow
notice that you need pip to be connected to python3, otherwise- python3 setup.py install (probably using sudo).
Hi,
I have a question regarding the 0 bit if the row starts with black - does it represent the first pixel, or should it be the first bit, and then only do we start coding the pixels of the fax?
Thanks
Another issue - how to we convert a Pixel Access object to an Image? I tried many of the PIL functions and none of them worked for this type of object…
Thanks
Please disregard the first question I misunderstood the instructions, however the issue with the Pixel Access is still a big problem.
Also, in the skeleton there is a referral to build_huffman_tree instead of make…
do we need to download the pil and numpy libarys? if so, which of them? there are many versions…
where we can find the convert method?
Here is a link where you can find PILLOW and NumPy:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
It doesn't matter which version, as long as it fits your windows version (32bit unless you know otherwise) and python version (3.2 unless you installed a different version then we suggested).
Had to change one of your built-in functions because of a wrong function name:
def huffman_code(corpus):
''' creates a Huffman encoding codebook and decodebook for the given corpus.
the corpus should be a list of integers representing run-lengths.
returns a tuple, the first value is the codebook and the second is the decodebook'''
counts = symbol_count(corpus)
#tree = build_huffman_tree(counts)
tree = make_huffman_tree(counts)
codebook = build_codebook(tree)
decodebook = build_decodebook(codebook)
return codebook, decodebook
Also, you are not consistent with the order of the size tuple,
Although you stated it is (height,width) in B, I think it should be (width,height) as (well, everywhere) in the Image class.
בדומה למה שאור אמר, יש כמה בעיות:
1. התכונה size של עצם מסוג Image מחזירה (width,height). בדרישות נרשם כי הפונקציה rle_decoding מקבלת (height,width). בקוד לדוגמה המצורף ב-PDF אתם משתמשים בתכונה size ולכן שולחים קודם את הרוחב ולא את האורך.. כנ"ל לגבי הפונקציה (segment_rows(rle_list, size. האם הפונקציות מקבלות באמת (width,height) כמו במחלקה Image (גם ()img.load מחזירה את הנתונים בצורה של width x height…)
2. בקובץ ה- skeleton ישנה טעות: הפונקציה huffman_code קוראת לפונקציה build_huffman_tree כאשר בפועל נתתם לה את השם make_huffman_tree
3. לא נתון גודל התמונה fax3 שנדרש בכדי לפרוס אותה…
4. בסעיף ד' רשום שיש להגיש כמה קבצים דחוסים ותמונה בנוסף לקובץ הפייתון וה-PDF, אך לא מצויין איך ואיפה צריך להגיש (האם בקובץ ZIP? איפה להגיש - האם עם קובץ הפייתון או עם קובץ ה-PDF?)
תודה רבה מראש!
בנוסף - יכול להיות שיש בעיה עם הפונקציה bitstring_to_file שכתבתם:
אם אורך המחרוזת הדחוסה לא מתחלק ב-8, אז התו האחרון שנכתוב בקובץ יעבור המרה בפחות מ-8 ביטים. במידה והיו אפסים בתחילת המחרוזת של תו זה, הם "יעלמו" בהמרה עם int. לאחר מכן, בפריסה מהקובץ (בפונקציה שאנחנו כותבים), לא ניתן לדעת אם היו אפסים ש"נמחקו" בתו האחרון משום שלא ידוע אורך המחרוזת המקורית ולכן נקבל פריסה לא טובה.. כדי שזה לא יקרה, לפני החלוקה למקטעים של 8 ביטים, צריך להשלים את המחרוזת הדחוסה באפסים כך שאורכה יתחלק ב-8.
נשמע נכון..?
You are right that writing the bitstring will most time append a few additional zero bits to the end of the file, and that the Huffman decompression might decode this to a new RLE that did not exist in the original image.
But if you know the size of the image when you decode the RLE this should not matter.
Thanks, this is will soon be corrected in the online .py file.
היי יואב,
ראיתי שלא תיקנתם גם את זה בקובץ פייתון:
בנוסף - יכול להיות שיש בעיה עם הפונקציה bitstring_to_file שכתבתם:
אם אורך המחרוזת הדחוסה לא מתחלק ב-8, אז התו האחרון שנכתוב בקובץ יעבור המרה בפחות מ-8 ביטים. במידה והיו אפסים בתחילת המחרוזת של תו זה, הם "יעלמו" בהמרה עם int. לאחר מכן, בפריסה מהקובץ (בפונקציה שאנחנו כותבים), לא ניתן לדעת אם היו אפסים ש"נמחקו" בתו האחרון משום שלא ידוע אורך המחרוזת המקורית ולכן נקבל פריסה לא טובה.. כדי שזה לא יקרה, לפני החלוקה למקטעים של 8 ביטים, צריך להשלים את המחרוזת הדחוסה באפסים כך שאורכה יתחלק ב-8.
נשמע נכון..?
האם זה אומר שזה לא נכון? ואם זה כן, אז צריך לתקן גם את הקובץ fax3.t4
תודה מראש!
You can workaround the problem using the image size, or just ignore it, it shouldn't add more than one or two extra pixel run length to your image.
in d section, we need to have fax3 image size for decompress it..
בסעיף ב', ההרצות שלנו צריכות להיות בדיוק כמו בדוגמא? מבחינת סדר והערכים במילון הקידוד?
בסעיף ב' - בניית עץ הפמן: מה הכוונה ב"העלים חייבים להיות מסודרים משמאל לימין בסדר עולה של המספרים בהם, וגם המספרים בתוך כל צומת פנימי חייבים להיות מסודרים בסדר עולה" ? אפשר לקבל דוגמה?
תודה מראש
You can disregard the restriction you quoted.
You are free to choose the build order of the Huffman tree when there are multiple build options.
From my experience, if you choose different build orders you get different Huffman trees and different decoding books.. so if you try to decode the fax from clause d using a different Huffman tree you won't be able to decompress it…
So if you choose to follow the restrictions in clause b you won't be able to decode the fax in clause d, as it uses the a different build order (the one demonstrated in the lectures).
היי.. כשאני מריץ את הפונקציה image2bitmap ומשנה את הconvert ל"1" במקום "L" על תמונה כלשהי הפייתון קורס לי ומוציא לי את ההודעה:
"pythonw.exe has encountered a problem and needs to close. We are sorry for the inconvenience."
למישהו יש פיתרון?
Read the instructions on the top right of the page about how to write hebrew in the forum.
As it is, it is hard to understand what you are asking.
I'll try to answer your question - what happens when you use it with "1"? Which image are you using?
I use the picture you uploaded to the site on the assignment page. I also tried using another one, which failed too.
When I use the "original" image2bitmap (with the "L" mode) it is all fine. But when I only change it to "1" mode as you asked for in that question I get that "don't send" error, and python crashes.
i had the same problem when i used numpy to get the matrix from the image
suddenly the values where true and false, instead of 0 and 255
so i converted twice the image, once to "1" so it will have only two tones
and back again "L" so i wouldnt have this bug.
and for some reason everytime it crashes after different time.