Click here to Skip to main content
15,894,146 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionVB.NET ,Event handling Pin
rajiv_kadam24-Aug-09 18:56
rajiv_kadam24-Aug-09 18:56 
AnswerRe: VB.NET ,Event handling Pin
Christian Graus24-Aug-09 19:09
protectorChristian Graus24-Aug-09 19:09 
AnswerRe: VB.NET ,Event handling Pin
Suresh Suthar24-Aug-09 19:12
professionalSuresh Suthar24-Aug-09 19:12 
Question[Message Deleted] Pin
Golden Jing24-Aug-09 17:28
Golden Jing24-Aug-09 17:28 
AnswerRe: How to convert double with currency to text ? Pin
Christian Graus24-Aug-09 19:07
protectorChristian Graus24-Aug-09 19:07 
GeneralRe: How to convert double with currency to text ? Pin
Golden Jing24-Aug-09 21:14
Golden Jing24-Aug-09 21:14 
QuestionHow to reach optimum performance when handling many image frames? Pin
Sonhospa24-Aug-09 6:26
Sonhospa24-Aug-09 6:26 
AnswerRe: How to reach optimum performance when handling many image frames? Pin
Luc Pattyn24-Aug-09 6:43
sitebuilderLuc Pattyn24-Aug-09 6:43 
Hi,

here are some answers and some thoughts:

1. when performance matters, I stay far away from multi-dimensional arrays, I use one-dimensional arrays instead. A simple reason is the compiler needs to translate arr[i,j] into an address calculation that involves at least one multiplication and one addition, something like i*jmax+j (plus multiplying by the number of bytes per element and adding the base address). The next time through the loop, both i and j could have changed; when I know I am stepping one way, I can simply add a constant to the one index I have in a one-dimensional array. This wins every time.

2. If GDI+ doesn't help you in your most time-consuming part of the job, then stay away from it. A 32-bit pixel value that you understand (and GDI+ doesn't) is fine by me.

3. Storing several images into the next dimension of an array does not make sense to me, as it doesn't bring any advantage. You can keep several frames each in a separate "bitmap" arrays (not the GDI+ one), and hold these in any collection you choose, say a List. Or an array, but then it is an array of arrays, quite different from a 2-D array.

4. Assuming all images in one run have the same size, I would NOT allocate new large objects as soon as everything has been set up, instead I would reuse them; this avoids:
- out-of-memory situations and GC cycles
- possibly cache trashing
There are two possible disadvantages:
- you must make sure you don't confuse old and new images (letting them fade away and be collected is easier and safer);
- you don't get the array initialized to all zeroes (often not relevant in image processing).

5. So I would come up with a Frames class, that knows how to allocate frames initially, and can recycle frames that got freed.

6. I would absolutely apply some kind of slicing, so all the data of interest can fit in L1 and L2 caches as much as possible. So rather than performing operations op1 and op2 consecutively on an entire image, I'd rather do op1 and op2 on the top 10% of the image, then the next 10%, etc. This can dramatically improve speed for some operations.

7. I always avoid copying data. The cost of image operations can be expressed as the number of multiplications, shifts, adds and compares; these are necessary to achieve the functions you are after; copying data does not achieve a thing, so try and avoid it.

8. For performance, be aware of the difference between debug and release builds. Debug builds are hardly optimized at all.

9. In C++ you would use pointers; in C# I would consider using pointers. In VB.NET you are a bit out of luck. VB isn't very appropriate for heavy stuff, let alone image processing.

10. If you're really an advanced programmer, you would consider using SIMD (that is the vector extensions to the x86 instruction set, known as MMX/SSE/... ) for such tasks; that would normally take a lot of tedious native code, however could be controlled by a VB app. I once did a Java image processing app that generated highly optimized SSE2 code at run-time and executed it.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

GeneralRe: How to reach optimum performance when handling many image frames? Pin
Sonhospa24-Aug-09 10:26
Sonhospa24-Aug-09 10:26 
GeneralRe: How to reach optimum performance when handling many image frames? Pin
Luc Pattyn24-Aug-09 11:00
sitebuilderLuc Pattyn24-Aug-09 11:00 
QuestionMulti column Drop down list in VB.NET (populating dataTable) Pin
sachinbb24-Aug-09 6:03
sachinbb24-Aug-09 6:03 
AnswerRe: Multi column Drop down list in VB.NET (populating dataTable) Pin
Henry Minute24-Aug-09 7:26
Henry Minute24-Aug-09 7:26 
GeneralRe: Multi column Drop down list in VB.NET (populating dataTable) Pin
sachinbb24-Aug-09 10:28
sachinbb24-Aug-09 10:28 
Questiondisplay image larger than the screen size Pin
TheMrProgrammer24-Aug-09 4:33
TheMrProgrammer24-Aug-09 4:33 
AnswerRe: display image larger than the screen size Pin
Luc Pattyn24-Aug-09 5:04
sitebuilderLuc Pattyn24-Aug-09 5:04 
GeneralRe: display image larger than the screen size Pin
TheMrProgrammer24-Aug-09 18:41
TheMrProgrammer24-Aug-09 18:41 
GeneralRe: display image larger than the screen size Pin
Luc Pattyn25-Aug-09 0:05
sitebuilderLuc Pattyn25-Aug-09 0:05 
Questionctype operator in Visual Basic; string to MySqlDateTime Pin
fabrice.leal24-Aug-09 1:34
fabrice.leal24-Aug-09 1:34 
AnswerRe: ctype operator in Visual Basic; string to MySqlDateTime [modified] Pin
Henry Minute24-Aug-09 2:16
Henry Minute24-Aug-09 2:16 
AnswerRe: ctype operator in Visual Basic; string to MySqlDateTime Pin
εїзεїзεїз24-Aug-09 3:24
εїзεїзεїз24-Aug-09 3:24 
AnswerRe: ctype operator in Visual Basic; string to MySqlDateTime Pin
fabrice.leal24-Aug-09 3:46
fabrice.leal24-Aug-09 3:46 
General...problem solved... I hope... Pin
fabrice.leal24-Aug-09 3:56
fabrice.leal24-Aug-09 3:56 
GeneralRe: ...problem solved... I hope... Pin
εїзεїзεїз24-Aug-09 5:00
εїзεїзεїз24-Aug-09 5:00 
Questionhow to press a button from a other applicationt ? Pin
vietphamvn23-Aug-09 20:54
vietphamvn23-Aug-09 20:54 
AnswerRe: how to press a button from a other applicationt ? Pin
Christian Graus23-Aug-09 21:26
protectorChristian Graus23-Aug-09 21:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.