Results 1 to 5 of 5

Thread: QVector to store 3d data

  1. #1
    Join Date
    May 2015
    Posts
    66
    Thanks
    10
    Thanked 17 Times in 17 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default QVector to store 3d data

    Hello,

    I have a data model and a GUI. In the data model I have a list of image data.
    Qt Code:
    1. QList<ImageData>
    To copy to clipboard, switch view to plain text mode 

    Each image data can hold a 3-dimensional vector of unit's.
    Qt Code:
    1. QVector< QVector< QVector<uint> > > m_3dData
    To copy to clipboard, switch view to plain text mode 
    .

    From the GUI I want to request a 2-dimensional slice from m_3dData, but in any order.

    As soon as GUI requests this, I need to calculate the minimum and maximum pixel values from the specified slice and create a auto scaled image from it and display in the GUI.

    The requested slice is typically in the range of 1 x 800 x 800 pixels wide. I access the vector using m_3dData[dim1][dim2][dim3] which results in 160,000 + 160,000 accesses (for getting min and maximum pixels once and for creating auto scaled rgb values from it again). This takes 50 + 50 milliseconds or so which is a lot for me.

    My questions are:
    • Is QVector the right structure for this purpose?
    • Is there a better way to access this structure?


    Thanks you!

    Regards
    Vikram

  2. #2
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QVector to store 3d data

    Can you tell a little bit about what it is used for, for me it is not clear what you are trying to achief.

    you can store 3d data in many different ways but it depends on the type of data and what you need to extract from the data.

  3. #3
    Join Date
    May 2015
    Posts
    66
    Thanks
    10
    Thanked 17 Times in 17 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QVector to store 3d data

    Hello StrikeByte,

    A image data generator (say 3D scanner) generates 64-bit data stream (each data represents a pixel). This stream has to be stored as a stack of images in the data model. GUI wants to show the building of image in real time at its own rate.

    The scanner can move in XYZ, XZY, YZX, YXZ, ZXY or ZYX depending on how it is configured.
    The user (GUI) can visualize XY, YX or XZ (which is the 2 dimensional slice I mentioned) as a gray scale QImage.

    Thanks for the interest and response!

    Regards
    Vikram

  4. #4
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QVector to store 3d data

    With you current approach, accessing an element requires lots of memory loads, because each QVector internally holds a pointer into the actual storage in the heap. In addition, implicit sharing could cost additional indirections, and accessing elements with [] for a non-const QVector means wasting time checking that its storage is not shared with others.

    You should try a flat array without sharing, such as an std::vector or QVarLengthArray. If the three dimensions are A, B, C, then the array should have length A * B * C, and the element with coordinates i, j, k will have index ((i * B) + j) * C + k. Make sure you call an accessor without bound checking.

  5. The following user says thank you to yeye_olive for this useful post:

    Vikram.Saralaya (18th November 2015)

  6. #5
    Join Date
    May 2015
    Posts
    66
    Thanks
    10
    Thanked 17 Times in 17 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QVector to store 3d data

    @yeye_olive

    That is indeed useful! I was just considering the QVarLengthArray and that is a confidence booster

Similar Threads

  1. Store data in bits & Bytes
    By 2lights in forum Newbie
    Replies: 3
    Last Post: 9th September 2013, 13:39
  2. How to store data in a tablemodel
    By rubikon in forum Newbie
    Replies: 11
    Last Post: 13th August 2012, 14:18
  3. Need ideas on how to store data in SQL-Database
    By homerun4711 in forum Newbie
    Replies: 3
    Last Post: 5th January 2011, 23:10
  4. Store QVector to QDataStream problem
    By ruben.rodrigues in forum Newbie
    Replies: 1
    Last Post: 2nd August 2010, 09:27
  5. How to store/get pointer on QTreeWidgetItem data?
    By Teerayoot in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2007, 22:26

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.