Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4097596
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:11:38+00:00 2026-05-20T20:11:38+00:00

import Image from numpy import zeros, asarray YUV = zeros((240, 320, 3), dtype=’uint8′) im

  • 0
import Image
from numpy import zeros, asarray
YUV = zeros((240, 320, 3), dtype='uint8')
im = Image.fromarray(YUV, mode="YCbCr")
blah = asarray(im)

When I run this (IPython 0.10.1 on Py 2.7.1) it seems to make python read some memory which it shouldn’t be reading. Sometimes it crashes, sometimes it doesn’t but I can surely make it crash by increasing the 320×240 zeros to, say, 3200×2400 and/or calling blah.copy(). Also, if I do:

from matplotlib import pyplot as p
p.subplot(221); p.imshow(blah[:,:,0])
p.subplot(222); p.imshow(blah[:,:,1])
p.subplot(223); p.imshow(blah[:,:,2])
p.subplot(224); p.imshow(blah[:,:,3])
p.gray()
p.show()

I start to see junk memory appearing in blah at around about row 180. What’s going on here? Am I converting from PIL Image to numpy array in a bad way? What is the difference between using array(im) instead of asarray(im), and what is preferred? (note in the former case it does still crash sometimes, but it seems to be more stable and less junk)

(Here’s a related question)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:11:38+00:00Added an answer on May 20, 2026 at 8:11 pm

    I noticed that your image is YCbCr 3-channel, but you’re displaying 4 channels. Turns out the “junk data” problem is caused by a bug in PIL’s array interface, and a fix was committed in Nov 2010. PIL’s array interface is returning a 4th channel.

    I ran your test case under PIL 1.1.7 and see the noise. I commented out the 224 subplot and re-ran your test using the latest PIL trunk code and a proper 3-channel array is produced, with no noise. The crashing may also be related, but I couldn’t reproduce that in my environment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an array thusly: import numpy as np data = np.zeros( (512,512,3),
I have a web project where I must import text and images from a
I am trying to convert a PIL image into an array using NumPy. I
I've seen from the sample how to display an image from the webcam, but
I am trying to extract an image frame from a video taken from iPhone
Is it possible to set the position of an image using pygtk? import pygtk
import sys words = { 1 : 'one', 2 : 'two', 3 : 'three',
I need to import a csv file into Firebird and I've spent a couple
How can you import a foxpro DBF file in SQL Server?
I want to import an oracle dump into a different tablespace. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.