Duyurular & Dokümanlar

BME4120 Lecture 7 Slides
Ders Notu
14.11.2024

BME4120 Lecture 7 Slides.

These will NOT be included in midterm exam.


BME4120 Filter code week7
Ders Notu
14.11.2024

import numpy as np

from skimage import io, color, img_as_float

from scipy.fft import fft2, ifft2, fftshift, ifftshift

from scipy.ndimage import zoom

import matplotlib.pyplot as plt


def homomorphic_filtering(image, d0=20, c=5., gamma_h=3.0, gamma_l=0.4):

    """

    Perform homomorphic filtering on the input grayscale image using the given H(u, v) function.

    

    Parameters:

        image (numpy.ndarray): Input grayscale image in float format.

        d0 (float): Cutoff frequency for the filter.

        c (float): Parameter controlling the filter's sharpness.

        gamma_h (float): High-frequency gain.

        gamma_l (float): Low-frequency gain.

    

    Returns:

        numpy.ndarray: Enhanced image after homomorphic filtering.

    """

    # Step 1: Ensure image is in float format and add small constant to avoid log(0)

    img_float = img_as_float(image)

    epsilon = 1e-6

    img_float = img_float + epsilon

    

    # Step 2: Apply log transformation

    img_log = np.log(img_float)

    

    # Step 3: Apply Fourier transform

    dft = fft2(img_log)

    dft_shift = fftshift(dft)

    

    # Step 4: Create the H(u, v) filter

    rows, cols = image.shape

    crow, ccol = rows // 2, cols // 2

    u = np.arange(rows).reshape(-1, 1) - crow

    v = np.arange(cols).reshape(1, -1) - ccol

    D = np.sqrt(u**2 + v**2)

    H = (gamma_h - gamma_l) * (1 - np.exp(-c * (D ** 2) / (d0 ** 2))) + gamma_l

    

    # Step 5: Apply the filter in the frequency domain

    S = dft_shift * H

    

    # Step 6: Inverse Fourier transform

    dft_inv_shift = ifftshift(S)

    img_back = ifft2(dft_inv_shift)

    

    # Step 7: Inverse log transformation and take real part

    img_exp = np.exp(np.real(img_back))

    print(img_exp)

    

    # Step 8: Normalize to [0, 1] range

    # img_enhanced = (img_exp - np.min(img_exp)) / (np.max(img_exp) - np.min(img_exp))

    img_enhanced = img_exp

    return img_enhanced


# Image loading and processing

def process_image(image_path, target_size=(256, 256)):

    """

    Load and preprocess image for homomorphic filtering.

    """

    # Load image

    input_image = io.imread(image_path)

    

    # Convert to grayscale if needed

    if input_image.ndim == 3:

        input_image = color.rgb2gray(input_image)

    

    # Resize to target size

    if input_image.shape != target_size:

        scale_factors = (target_size[0] / input_image.shape[0], 

                        target_size[1] / input_image.shape[1])

        input_image = zoom(input_image, scale_factors)

    

    return input_image


# Main execution

if __name__ == "__main__":

    # Load and process image

    image_path = 'selected_images/00000001_000.png'

    input_image = process_image(image_path)

    

    # Apply homomorphic filtering

    enhanced_image = homomorphic_filtering(input_image, d0=20, c=5.0, gamma_h=3.0, gamma_l=0.4)

    

    # Display results

    plt.figure(figsize=(10, 5))

    

    plt.subplot(1, 2, 1)

    plt.title('Original Image')

    plt.imshow(input_image, cmap='gray')

    plt.axis('off')

    

    plt.subplot(1, 2, 2)

    plt.title('Enhanced Image')

    plt.imshow(enhanced_image, cmap='gray')

    plt.axis('off')

    

    plt.show()

BME4903 Lecture 5 Slides
Ders Notu
8.11.2024

BME4903 Lecture 5 Slides


BME4120 Lecture 6 Slides
Ders Notu
7.11.2024

BME4120 Lecture 6 Slides


BME4120 Lecture 6 Codes
Ders Notu
7.11.2024

BME4120 Lecture 6 Codes


BME4903 Lecture 4 Slides
Ders Notu
1.11.2024

BME4903 Lecture 4 Slides


BME4120 Lecture 5 Slides
Ders Notu
31.10.2024

BME4120 Lecture 5 Slides


BME4120 Lecture 4 Slides
Ders Notu
31.10.2024

BME4120 Lecture 4 Slides


BME4903 Lecture 3 Slides
Ders Notu
18.10.2024

BME4903 Lecture 3 Slides


BME4120 Lecture 3 Slides
Ders Notu
17.10.2024

BME4120 Lecture 3 Slides


BME4903 Lecture-2 Slides
Ders Notu
11.10.2024

BME4903 Lecture-2 Slides


BME4120 Lecture 2 Slides
Ders Notu
10.10.2024

BME4120 Lecture 2 Slides


BME4903 Lecture-1 Slides
Ders Notu
4.10.2024

BME4903 Lecture-1 Slides


BME4120 Lecture-1 Sides
Ders Notu
3.10.2024

BME4120 Lecture-1 Sides


BME5006 Lecture Materials
Ders Notu
20.05.2024


Original Code:

https://omlc.org/software/mc/mcml-src/

Original Code manual:

https://omlc.org/software/mc/man_mcml.pdf


Python code:

working.zip is attached.

To run:

install python 3.11 or later

install numpy

then

python mcmlmain.py


BME4570 Lecture Slides
Ders Notu
20.05.2024

BME4570 Lecture Slides


BME3330 Lecture 8 Slides
Ders Notu
15.05.2024

BME3330 Lecture 8 Slides


BME4570 Lecture Notes Spectroscopy-2
Ders Notu
11.05.2024

Spectroscopy-2 slides are attached.


BME5006 Lecture Materials
Ders Notu
1.05.2024

Here you will find the lecture materials. PDF is the paper we followed during the lecture.

The codes developed by the authors is here:

https://omlc.org/software/mc/mcml-src/

The python code we started is still in progress and can be accessed from here:

https://tyetkin.web.cern.ch/tyetkin/code_conversion.py
The code is not complete and it will not work. We will continue to work on it.


BME3330 Lecture 6-7 Notes
Ders Notu
1.05.2024

BME3330 Lecture 6-7 Notes


BME4570 Lecture 7-8 Notes
Ders Notu
1.05.2024

BME4570 Lecture 7-8 Notes


BME4570 Quiz 1 Answers
Sınav
8.04.2024

BME4570 Quiz 1 Answers


BME3330 Quiz 1 Answers
Sınav
8.04.2024
BME3330 Lecture 5 Slides
Ders Notu
3.04.2024

BME3330 Lecture 5 Slides


BME4570 Lecture 6 Slides
Ders Notu
2.04.2024

BME4570 Lecture 6 Slides


BME4570-Lecture5 Slides
Ders Notu
1.04.2024

BME4570-Lecture5 Slides


BME3330 Lecture 4 Slides
Ders Notu
25.03.2024

BME3330 Lecture 4 Slides


BME3330 Lecture 3 Notes
Ders Notu
13.03.2024

BME3330 Lecture 3 Notes


BME4570 Lecture 4 Slides
Ders Notu
12.03.2024

BME4570 Lecture 4 Slides


BME5006 Lecture 4 Slides
Ders Notu
12.03.2024

BME5006 Lecture 4 Slides


BME5006 Project Topics
Duyuru
12.03.2024

BME5006 Project Topics

Utkan 11
Ugur 3
Mohammad 6
Beyza 9
Berivan 10
Ceren 13
Rumeysa 12
Irem 5
Kutalmis 14
Ezgi 8
Nisanur 1
Yunus Emre * kendi konusu
Seyma 15
Feyza 4
Melike  2
Sevval 24
Mustafa Cem Aksu 20
Rukiye Ozcanli 17
Serhat Unalan 19
Rukiye Akyuz Kendi Konusu
Emrah Aygun 7
Edanur Aciksoz 26


BME5006 Lecture 3 Notes
Ders Notu
5.03.2024

BME5006 Lecture 3 Notes


BME4570 Lecture 3 Slides
Ders Notu
5.03.2024

BME4570 Lecture 3 Slides


BME3330 Lecture-2 Slides
Ders Notu
28.02.2024

BME3330 Lecture-2 Slides


BME5006 Lecture-2 Notes
Ders Notu
26.02.2024

BME5006 Lecture-2 slides are attached.


BME4570 Lecture 2 Slides
Ders Notu
26.02.2024

BME4570 Lecture 2 Slides


BME3330 Lecture-1 Slides
Ders Notu
24.02.2024

BME3330 Lecture-1 Slides


BME4570 Lecture-1 Slides
Ders Notu
24.02.2024

BME4570 Lecture-1 Slides


BME5006 Syllabus & Lecture 1 Note
Ders Notu
19.02.2024

BME5006 Syllabus & Lecture 1 Note are attached.

Code tutorial is moved here:


Code repo for short tutorial:

https://github.com/tyetkin/mc-light-propagation-tissue/blob/main/README.md

Video tutorials:

Python training videos:

Short videos:

https://www.youtube.com/watch?v=kqtD5dpn9C8&pp=ygUXaW50cm9kdWN0aW9uIHRvIHB5dGhvbiA%3D
https://www.youtube.com/watch?v=b093aqAZiPU&pp=ygUXaW50cm9kdWN0aW9uIHRvIHB5dGhvbiA%3D

A full Pyhton Course Video:
https://www.youtube.com/watch?v=nLRL_NcnK-4&pp=ygUXaW50cm9kdWN0aW9uIHRvIHB5dGhvbiA%3D