Tuesday, May 23, 2017

Chaotic fractals of mandelbrot

f(z) = z^2 + C
where z is a complex number (vector)
and C is a complex constant (vector of a constant norm)

output from my Xcode project:

for(i=0; i <iter;i++){
        float x = (z.x * z.x - z.y * z.y) + c.x;
        float y = 2.0 * (z.x * z.y) + c.y;

if((x * x + y * y) > 40.0break//distance from the origin>2 ==> done!!
        z.x = x;
        z.y = y;

After 355 iterations:

PCB Inspector with pytrack

One of my friends gently asked me to help them on automatic inspection of PCBs (xray).

I used pytrack to investigate and report soldering failures (bad bubbles). 

# -*- coding: utf-8 -*-
# 07.05.2017
# porsuk
from __future__ import division, unicode_literals, print_function  # for compatibility with Python 2 and 3
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pandas import DataFrame, Series  # for convenience
from scipy import ndimage
from skimage import morphology, util, filters
import pims
import trackpy as tp
def crop(img):
    Crop the image to select the region of interest
    x_min = 20#745
    x_max = -25#850
    y_min = 50#225
    y_max = -250#300
    return img[y_min:y_max,x_min:x_max]
def rgb2gray(rgb):

    r, g, b = rgb[:,:,0], rgb[:,:,1], rgb[:,:,2]
    gray = 0.2989 * r + 0.5870 * g + 0.1140 * b

    return gray
def preprocess_pcb(img):
    Apply image processing functions to return a binary image
    # Crop the pictures as for raw images.
    img = crop(img)
    # Apply thresholds
    img = filters.threshold_adaptive(img, 57)
    threshold = 0.9
    idx = img > img.max() * threshold
    idx2 = img < img.max() * threshold
    img[idx] = 0
    img[idx2] = 3
    img = ndimage.binary_dilation(img)
    img = ndimage.binary_dilation(img)
    return util.img_as_int(img)
frames = pims.ImageSequence('*.jpg',process_func=preprocess_pcb)
for frame in frames:
     f = tp.locate(frame, percentile=10,diameter=77, minmass= 3.0e+07,separation=80,threshold=1/30)
     print('frame = ',f['frame'][0] )
     print('max bubble percentage: ', 20 * max(f['size']) / 250 )
     plt.figure(f['frame'][0])  # make a new figure

DIY 4-way vacuum valve to engage 4wd(subaru justy oem 4wd valve failure)

 Broken oem 4-way valve: Tried epoxy but did not fixed it. Actually epoxy sealed the vacuum leak but most probably solenoid was gone.

Monday, May 22, 2017

DIY forester rear wheel bearing replacement

was very ezy and straight forward except breaking the brake line (obtain propper wrench to loose yours). Bleeding alone may be another challenge but i used pipe and bottle method w/o any problem.

 final and true drum brake instrument re-installation (above pics was taken during unsuccessful attempts):

 Thanx to helpful machinist for installing new bearing in press. (so DIY except pressing)

 ready to install:

91 MY LN130 Hilux Surf A/C Condenser Relocation

Relocation of the underslung a/c condenser of hilux surf to in front of the radiator. 
Tested against highway and city speeds w/o any increase in coolant temp. btw oem rad. fan re-wired in-order to start manually. and always kicked on city speeds. But not sure if needed to start or not since i did not installed digi temp gauge so i was  monitoring just analog oem one. At the end, it was a successful project. Could be better if i had alu welder.
But for those thinking about carrying the a/c condenser to behind of the grill, i can exactly say that suspicious ln130 radiator was not blocked (to overheat) by the a/c condenser.

DIY 2nd Gen 4runner (Hilux Surf) grab handle installation

91 MY 2nd gen 4runner (ln130 hilux surf actually) front driver and passenger side vertical grab handle installation:
1 - nice front prado grab handles from wrecker.
2 - back grab handles from 98MY vx80.
3 - M6 15mm alu rivet nuts. The only option was novus from bauhaus.
4 - 9mm drill bit.
5 - pictures tell the remaining. (btw my homemade rivet nut installation tool worked great for me)

was great fun...

Saturday, November 12, 2016

ParticleSLAM Differential Jacobian Method

Monday, July 07, 2014


Fatih's weblog hayatına son vermiştir.

Wednesday, August 17, 2011


Sunday, September 12, 2010

ImageMagick montage (creating picture collages)

Using Gimp  takes much time unless you are familiar with layers etc. Picasa 2 in ubuntu 9.04 does not give permission to customize the collage maker's options (like background color, positioning, gap etc.). So ImageMagick is a good choice to create collages.

An easy way of creating collages with ImageMagick:

montage *.jpg collage.jpg

or consider there are plenty of files in a directory named such as xy.jpg, xy1.jpg, xy2.jpg, xy3.jpg, ..., you can specify the filenames to be montaged (also border type and color, etc.) as:

# montage filesToBeMontaged -theBorderType # -theBorderColor # -theGapBetweenPictures +#+# resultantCollage
montage x{y,y1,y2,y3}.jpg -border 5 -bordercolor darkyellow -geometry +2+2 collage.jpg

Here are the other very useful examples.

Labels: ,

Thursday, August 12, 2010

DIY: Subaru Forester Spark Plug Wire Set Replacement

I replaced the old OEM spark plug wire set with Exact OEM fit of NGK FX54 8772 Wire Set.
Although the old wire set resistance values were still in bound of the spec, i decided to change them since they were very close to the upper limit. Here are the resistance values per cable:

Wire order:
rear of car
   3 4
   1 2
 front o car

 Wire resistance of my forester and Ref. values:
                Wire resistance of my Forester:     Wire resistance specs:
                 [kOhms]                                       [kOhms]

#1 cord:     12.3                                             7.40 — 17.27
#2 cord:     11.6                                             6.24 — 14.56
#3 cord:     11.8                                             6.54 — 15.25
#4 cord:     14.6                                             6.59 — 15.37

Replacement was very easy it took about 10 minutes. NGK indicates the cylinder lead ID on each cord.
Start with putting the spark plug part of cord first and then continue with following the same way with the old wire, that is it.

I bought wire set from www.ClubPlug.net of CA. They got it from NGK dist. on Thursday and sent to Toronto by the Prulator next day shipping at around 4:30 pm. It was at the hotel by 10:30 am. I should send my thanks to them, of course also to my friend Murat who brought them to me.

Labels: ,