Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41070

working with dict : incrementing dict dynamically

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <insideshoes@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; '"__main__":': 0.07; 'pixel': 0.07; 'blue': 0.09; 'dict': 0.09; 'advance': 0.10; 'def': 0.10; '0.0,': 0.16; '65536': 0.16; 'thanx': 0.16; 'to:name:python-list@python.org': 0.20; 'trying': 0.21; 'import': 0.21; 'skip:c 70': 0.22; 'values': 0.26; 'set.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'dictionary': 0.29; 'falls': 0.29; 'subject: : ': 0.30; 'code': 0.31; 'print': 0.32; 'to:addr:python-list': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'identified': 0.35; 'continue': 0.35; 'something': 0.35; 'created': 0.36; 'but': 0.36; 'subject:with': 0.36; 'data': 0.37; 'green': 0.38; 'to:addr:python.org': 0.39; 'red': 0.60; 'first': 0.61; 'here': 0.65; 'color': 0.69; '8bit%:100': 0.70; '3000': 0.71; 'increase': 0.72; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=M5TAW/FBBRF1mRwQaqOqBe/IhRCvsiG9jc0B7wz1N5Y=; b=mVqpR92JTw9rrhEJ//KfFUlH8mDrt3wFebUTXpWeHUAXuqTbgH4gU+PhoP1+0mwOJd DIIU3VoPk7Dg4eSRRP4GddLrDkK+9L8KkVAJ56eEUX7tjbZNquJ0uoc0KfNVagWkr2Us cNxO3Thw2OG6cdxqo2mMYet/z14QZWHHU0NGuc8IA/ZbY+fmabvo55hVkJqIQkkiai6E UbqunY10R0XwG55YHcTiHEwUnn0kYByicwVDdzOQEGyQUAuFRV6/1PqbJymSbFmfoM3H JRcOZeiGaBeCb80lVeRg8TRYc359rORO88aztxwgGYO425bBSN3cJPKAgCxayY3c2jdX g1YA==
MIME-Version 1.0
X-Received by 10.50.212.38 with SMTP id nh6mr7494116igc.72.1363015385762; Mon, 11 Mar 2013 08:23:05 -0700 (PDT)
Date Mon, 11 Mar 2013 16:23:05 +0100
Subject working with dict : incrementing dict dynamically
From inshu chauhan <insideshoes@gmail.com>
To "python-list@python.org" <python-list@python.org>
Content-Type multipart/alternative; boundary=14dae93408ffe4594104d7a7bf0c
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3191.1363015388.2939.python-list@python.org> (permalink)
Lines 81
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363015388 news.xs4all.nl 6966 [2001:888:2000:d::a6]:48475
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41070

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

I am trying to create a dictionary with a key and its values seraching from
a data set. But something is going wrong. This is the first time I am
working with dicts.

My code is :

import cv
def Computesegclass(segimage):
    num_pixel = 0
        for y in xrange(0, segimage.height):
        for x in xrange(0, segimage.width):

            if segimage[y,x] == (0.0, 0.0, 0.0):
                continue
            else:
                color = segimage[y,x]
                blue = color[0]
                green = color[1]
                red = color[2]
                region_num = blue + 256 * green + 65536 * red
                print region_num
                segments = dict({region_num : num_pixel})
                if region_num == region_num:
                    num_pixel = +1
                print segments

if __name__== "__main__":
    segimage =
cv.LoadImageM("Z:/Segmentation/segmentation_numbers_00000.tif",
cv.CV_LOAD_IMAGE_UNCHANGED)
    print segimage
    Computesegclass(segimage)


here I am traversing through an image which is 3000 x 3000. for each pixel
I calculate a region number. What I am trying to do is increase the
num_pixel by 1 if that pixel falls in the same region which is identified
by region_num. How can I do it in dict created ?

Thanx in Advance

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

working with dict : incrementing dict dynamically inshu chauhan <insideshoes@gmail.com> - 2013-03-11 16:23 +0100
  Re: working with dict : incrementing dict dynamically John Gordon <gordon@panix.com> - 2013-03-11 15:37 +0000

csiph-web