Thursday, October 6, 2011

Matlab: SURF, creating a surface.

I have no problems admitting that i am not a smart person at all.  When it comes to programming/mathematics/image processing/medical imaging analysis, every day, i make sure i tell myself i am a  real novice and there are boundless rooms for me to improve.

Just like one of Matlab's function: SURF/SURFACE.  The function creates a surface based on a matrix or columns(x,y, and/or z).  Reading Matlab's help on surf bewildered me further.   My intention was simple.  I wanted to create a surface, but i didn't have a z function and my z was not anyhow defined by x and y.  If my z is well defined, i might as well have a pretty good model for what i am trying to do.

Anyway, imagine that you just want to create a square plane.  How do you do it with surf ?

After fiddling with this and that, reading this and that, i finally realized what needs to be understood.

Say, i want to create a 2 x 2 plane flattened on z = 2 using coordinates.
As unintelligent as this might look, i could actually go by doing the followings:

> x = [-1  1; -1 1];
> y = [-1 -1;  1 1];
> z = [ 2  2;  2 2];
> surf(x,y,z); 

For a smart person like you, you should already recognize the that there are 4 x-y-z points (-1 -1 2), (1 -1 2), (-1 1 2), and (1 1 2). Note that even you know z is 2 across the whole plane. You cannot just input 2. You need a MxN matrix (which happens to be the M and N of X or Y), which makes sense other wise, Matlab won't know how to reconstruct that plane. In the above case, it will be a 2 x 2 matrix. This might seem introductory to you. But it gives me a better understanding of making a surface in matlab.

Thursday, September 1, 2011

What should be disposed in your Flex Codes? (possible flex memory leaks)

According to the well-written article here, there are several possible scenarios which would lead to memory leaks.

1) You started a timer but forgot to destroy it (remove)
2) You created an event listener, but forgot to destroy it (remove)
3) You created loader objects, but forgot to destroy it (remove)
4) You created variables (references), but forgot to destroy it (null, empty array)
5) You created an annoymous handler, and you cannot destroy it ( #sigh )


The Flow for making JPIP streaming possible from a DCM4CHEE (manually)

This documents my way to get the DCMs to output to a JPIP Stream

You will need:

1) A remote archive( preferably, if not try local) DICOM archive (supports dicom queries)
2) DCM4CHEE (unzipped)
3) Kakadu JPIP Server and Client (you can sub this in with others)
4) DCMTK

Pseudo-Steps:

1) Retrieve Images from a remote archive


a) set up a dcmrcv
> dcmrcv AE_TITLE@11112 -dest H:\Folder


b) cmove from a remote archive to dcmrcv
> dcmqr -L AE_TITLE@LOCALMACHINE AE_TITLE@REMOTEMACHINE:PORT -cmove AE_TITLE -qPatientID=1234567 -cstoredest /tmp


2) Convert 'cmove'ed images to a kakadu encoder-compatible format

a) this step is a bit important if your remote archive tends to store everything to a jpeg-ls or jpeg lossless format with different process tables).  Step a) is to ensure it will be converted to explicit big endian (which dcmtk knows what it is.
>DCM4CHEE\DCM2DCM "H:\Folder\abc.dcm" "H:\Folder\convertedabc.dcm" 

b) Convert to PGM with DCMTK
> DCMTK\DCMP2PGM "H:\Folder\convertedabc.dcm" "H:\Folder\convertedabc.pgm"

c) Convert to JP2 with Kakadu
> Kakadu\kdu_compress -i "H:\Folder\convertedabc.dcm" -o "H:\Folder\convertedabc.jp2" -rate 1.0




3) Start JPIP Server

*assuming you have moved convertedabc.jp2 to a place where the server knows where to read from
> kdu_server -address localhost -port 8080

4) Start JPIP Client
Just make sure your JPIP Url is correct and the target file is convertedabc.jp2 (in this example).






There, that'd do it.  If not, email me or leave me a comment for me to analyze your situation.  Thanks!!


Security Issues of Web Apps



Your web app is likely to be constantly under attack!  
Just take a look at the following list!



Common Concerns
Secure Messaging
Protection of Resources
Negotiation of Contracts
Trust Management


Common Attacks against Web Services
Reconnaissance Attacks
Dictionary Attack
Forceful Browsing Attack
Directory Traversal Attack
WSDL Scanning
Sniffing
Privilege Escalation Attempts
Format String Attacks
Exploiting Unprotected Administrator Interfaces

Attacks on Confidentiality
Registry Disclosure Attacks

Attacks on Integrity
Parameter Tampering
Coercive Parsing
Schema Poisoning
Spoofing of UDDI/ebXML messages
Principal Spoofing
Routing Detours
External Entity Attack
Cannoicalization
Intelligent Tamparing
Impersonation

DOS attacks
Flooding attacks
Recursive Payloads sent to XML Parsers
Buffer overflow exploits
Race Conditions
Symlink Attacks
Memory Leak Exploitation
Command Injection
SQL Injection
XML injection

Malicious Code Attacks

URL String Attacks
Parameter Tampering
Cross-site Scripting
Session Hijacking
Malformed Content
Logic Bombs Trapdoors/Backdoors




Reference:
Sangwan S. and Sangwan YS. (2010)  "Designing a Frame Work for Web Application Information Security Architecture".  International Journal of Electronics Engineering 2(2):337-380

Wednesday, August 31, 2011

DICOM Transfer Syntax UID

1.2.840.10008 is reserved for DICOM Transfer Syntaxes

Below is the set of UIDs for a number of  Transfer Syntaxes

Implicit VR Little Endian
1.2.840.10008.1.2
Explicit VR Little Endian Transfer Syntax
1.2.840.10008.1.2.1
Explicit VR Big Endian Transfer Syntax
1.2.840.10008.1.2.2
RLE Compression
1.2.840.10008.1.2.5
Deflated Explicit VR Little Endian
1.2.840.10008.1.2.1.99
JPEG Baseline
(JPEG Coding Process 1)
1.2.840.10008.1.2.4.50
JPEG Extended
 (JPEG Coding Process 2)(8-bit)
(JPEG Coding Process 4)(12-bit)
1.2.840.10008.1.2.4.51
JPEG(lossless, non-hierarchical) (JPEG Coding Process 14)
1.2.840.10008.1.2.4.57
JPEG (lossless, non-hierarchical, first-order prediction) (JPEG Coding Process 14)
1.2.840.10008.1.2.4.70
JPEG-LS  (Lossless Mode)
1.2.840.10008.1.2.4.80
JPEG-LS (Near Lossless Mode)
1.2.840.10008.1.2.4.81
JPEG 2000 Part 1(Lossless)
1.2.840.10008.1.2.4.90
JPEG 2000 Part 1(Lossless or Lossy)
1.2.840.10008.1.2.4.91
JPEG 2000 Part 2(Lossless)
1.2.840.10008.1.2.4.92
JPEG 2000 Part 2(Lossless or Lossy)
1.2.840.10008.1.2.4.93
JPIP
1.2.840.10008.1.2.4.94
JPIP (Referenced Deflate)
1.2.840.10008.1.2.4.95
MPEG2 MP@ML
1.2.840.10008.1.2.4.100
MEPG2 MP@HL
1.2.840.10008.1.2.4.101
MPEG4 AVC/H.264
1.2.840.10008.1.2.4.102
MPEG4 AVC/H.264 BD
1.2.840.10008.1.2.4.103


I have put together a table like this for my future reference.

Sunday, August 28, 2011

Deploying Flex Apps to iOS Devices

This entry documents what i did to deploy my flex apps to iOS Devices.

Pre-requisites:
A.1) Flash Builder 4.5(preferably with Flex SDK 4.5.1)
A.2) Air 2.6+
A.3) A registered Apple Developer's Account

You will then need:
B.1) A certificate from your Developer's Account (in iOS Provisioning Portal > Certificates)
* if your certificate has expired, you will then need to revoke your certificate, and renew all provisioning profiles*
B.2) A provisioning profile (in iOS Provisioning Portal > Provisioning)



Steps to build and deploy Flex Apps to iOS Devices
1) New Flex Mobile Project (check those that are needed, check iOS of course).
2)
a) to run in simulator, you just have to select 'On Desktop'
b) to run in device, you will need to select 'On Device' (and then select the appropriate packaging method)
If you intend to run in the device, you will need to configure the package settings. 

Where it says "Certificate", input what you derive from B.1.  Where it says Provisioning File, input what you derive from B.2.

3) Click Apply and click Run.
4) You will the be prompted to enter the password that has been paired up with your certificate.

5) After that, it will start packaging and it can take several or a very, very long time (if you select the Standard Packaging Method).
6) It will then tell you that it has packaged to an output directory.

7) Right click on the   .ipa   file and open in iTunes
8) Note that if you have a copy of the app in your iOS device, make sure you have it uninstalled
9) in the App tab of your device in iTunes, make sure your app is checked and then sync the device
10)  Run your app in your iOS Device and DONE!








Tuesday, August 16, 2011

HIGH FIBRE DIET

Everyone of us, as it is recommended, needs to intake 30g of fibres every single day.
Here is a list i dup-ed.  Meat and eggs do not have fibers.

HIGH FIBER FOODS LIST with TOTAL FIBER GRAMS (g)

 Fresh & Dried Fruit Serving SizeFiber (g)
 Apples with skin 1 medium5.0
 Apricot 3 medium1.0
 Apricots, dried 4 pieces2.9
 Banana 1 medium3.9
 Blueberries 1 cup4.2
 Cantaloupe, cubes 1 cup1.3
 Figs, dried 2 medium3.7
 Grapefruit 1/2 medium3.1
 Orange, navel 1 medium3.4
 Peach 1 medium2.0
 Peaches, dried 3 pieces3.2
 Pear 1 medium5.1
 Plum 1 medium1.1
 Raisins 1.5 oz box1.6
 Raspberries 1 cup6.4
 Strawberries 1 cup4.4

 Grains, Beans, Nuts & Seeds Serving SizeFiber (g)
 Almonds 1 oz4.2
 Black beans, cooked 1 cup13.9
 Bran cereal 1 cup19.9
 Bread, whole wheat 1 slice2.0
 Brown rice, dry 1 cup7.9
 Cashews 1 oz1.0
 Flax seeds 3 Tbsp.6.9
 Garbanzo beans, cooked 1 cup5.8
 Kidney beans, cooked 1 cup11.6
 Lentils, red cooked 1 cup13.6
 Lima beans, cooked 1 cup8.6
 Oats, rolled dry 1 cup12.0
 Quinoa (seeds) dry 1/4 cup6.2
 Quinoa, cooked 1 cup8.4
 Pasta, whole wheat 1 cup6.3
 Peanuts 1 oz2.3
 Pistachio nuts 1 oz3.1
 Pumpkin seeds 1/4 cup4.1
 Soybeans, cooked 1 cup8.6
 Sunflower seeds 1/4 cup3.0
 Walnuts 1 oz3.1

 Vegetables Serving SizeFiber (g)
 Avocado (fruit) 1 medium11.8
 Beets, cooked 1 cup2.8
 Beet greens 1 cup4.2
 Bok choy, cooked 1 cup2.8
 Broccoli, cooked 1 cup4.5
 Brussels sprouts, cooked 1 cup3.6
 Cabbage, cooked 1 cup4.2
 Carrot 1 medium2.6
 Carrot, cooked 1 cup5.2
 Cauliflower, cooked 1 cup3.4
 Cole slaw 1 cup4.0
 Collard greens, cooked 1 cup2.6
 Corn, sweet 1 cup4.6
 Green beans 1 cup4.0
 Celery 1 stalk1.1
 Kale, cooked 1 cup7.2
 Onions, raw 1 cup2.9
 Peas, cooked 1 cup8.8
 Peppers, sweet 1 cup2.6
 Pop corn, air-popped 3 cups3.6
 Potato, baked w/ skin 1 medium4.8
 Spinach, cooked 1 cup4.3
 Summer squash, cooked 1 cup2.5
 Sweet potato, cooked 1 medium4.9
 Swiss chard, cooked 1 cup3.7
 Tomato 1 medium1.0
 Winter squash, cooked 1 cup6.2
 Zucchini, cooked 1 cup2.6

Almost all of the foods i dislike have good amount of fibres.  
Basically, more veggie, and some more fruits and some more beans!  Less meat and egg.

In hk, theres a list of prepackaged snacks compiled by HKNA
http://www.hkna.org.hk/en/Snack_DB_2011_Food_Items_EN_21.2.2011.pdf