Friday, December 30, 2011

Testing fsolve and anonymous function

I have got a need to solve equations repeatedly whose coefficients are changing with each iteration. MatLab function 'fsolve' is tested using function handle and anonymous function as follows.
s=[3 7 11];
d=[1 3 5];
%ans= (2,1), (5,2), (8,3)
for i=1:3
x0 = [-5; -5]; % Make a starting guess at the solution
myfun =@(x) [x(1) + x(2) - s(i);
x(1) - x(2) - d(i)];
[x,fval] = fsolve(myfun,x0)  % Call 

Friday, December 16, 2011

Hand, Foot and Mouth Disease (HFMD)

My baby got blister-like rash on her hands and feet last week. Doctor said it may be caused by HFMD or flu. I found out later that it was the flu in my daughter case. I have never heard of HFMD before and that is why I re-share a brochure from KK hospital.
Q. What is hand, foot and mouth disease (HFMD)?
A. This is an infectious disease caused by a family of viruses called Enteroviruses, the commonest being the Coxsackie virus and Enterovirus. It can occur in people from various age groups, especially in pre-schoolers. It is a very common disease in Singapore and has been in existence for many years. It is not a rare or new disease.

Q. How do you know if your child has HFMD?
A. Children with HFMD will have blister-like rash on hands, feet and buttocks, mouth ulcers and fever. In addition, the child may have a sore throat, runny nose, vomiting and diarrhoea, and may feel tired. You may bring your child to the polyclinic or see your family doctor. There is no need for you to rush your child to the Children's Emergency just to confirm the diagnosis of HFMD.

Q. How can your child get HFMD?
A. HFMD can be easily spread through direct contact with nose discharge, saliva, faeces and fluid from the blisters.

Q. Is this disease serious?
A. The disease is usually mild and most children will recover in about a week's time. Only very rarely do certain rare strains of the virus cause complications such as inflammation of the brain and heart.

Q. Is HFMD treatable?
A. There is no specific treatment for HFMD. The symptoms are usually mild and children usually recover well as their own immune system fights off the virus. Your doctor will give medication to control the fever. You should encourage your child to take as much oral fluids as possible. Your child may not have a good appetite because swallowing may be painful. However, ensure that your child has adequate fluid to prevent dehydration. Offer your child small amount of fluid such as diluted fruit juice, rice or barley water every half hourly and about 10 to 30 ml each time throughout the day. Antibiotics are ineffective because this is a viral, not a bacterial infection.

Q. Does a prior infection with enterovirus make a person immune?
A. Specific immunity can occur, but a second episode is possible from a different strain of virus belonging to the enterovirus family.

Q. What can be done to prevent the spread of this disease?
A. Infected children should not be allowed to go to school, childcare centres and other crowded places until he is fully recovered. Practise good general hygiene. Wash your hands immediately after contact with the infected child or handling diaper changes, and before handling food. Prevent other children from contact with toys, books, eating utensils, towels, clothes and other personal items used by the infected child.

Q. When should a child with HFMD be brought to the Children's Emergency?
A. Most children with HFMD are relatively well and active despite their illness. Your family doctor or the polyclinic will be able to manage the majority of the cases. However, you should bring your child to the Children's Emergency if he develops any of the following problems:
*When the oral intake of fluids is poor, or when the child is unable to swallow, or vomits persistently.
*When the tongue is dry, or when the child has decreased urine output (dehydration).
*If the child appears lethargic, drowsy or irritable, is crying persistently, or is disoriented.
*When seizures occur.
*If there is difficulty in breathing.
*If the child looks ashen, pale or blue.
*If the child complains of acute headache or giddiness, or if there is neck stiffness.

Geometric Template Matching in LabVIEW

In NI's IMAQ Vision Concepts Manual, geometric template matching is described as follows. Geometric matching locates regions in a grayscale image that match a model, or template, of a reference pattern. Geometric matching is specialized to locate templates that are characterized by distinct geometric or shape information. When using geometric matching, a template is created that represents the object to be searched. Machine vision application then searches for instances of the template in each inspection image and calculates a score for each match. The score relates how closely the template resembles the located matches. Geometric matching finds template matches regardless of lighting variation, blur, noise, occlusion, and geometric transformations such as shifting, rotation, or scaling of the template.
The VIs such as IMAQ Find CoordSys (Pattern) 2 are used to locate the model. The template for the model is created as discussed in the following steps.
Open Template Editor in Windows by clicking Start -> All Programs -> National Instruments -> Vision -> Template Editor. Click File menu->New Template.... Select Geometric Matching Template (Edge Based) and browse an image to extract the template from. In the Select Template Region tab, define a region. For example, start at (200,300) and drag the mouse cursor to (232,332) and release it. Then, you can move the selection to the desired location. In the Define curves tab, specify curve parameters, e.g., Extraction mode to normal, Edge Threshold to 32, Edge Filter size to Fine, Minimum Length to 5, Row Search Step Size to 1 and Column Search Step size to 1. The setting in Customize Scoring and Specify Match Options tabs are set as default. Save the template by clicking File -> Save Template....
As an example, I have created a few VIs at the following link.

Geometric Template Matching on GitHub

Initialization for the VI inputs is shown below.