Research ⬦

Papers ⬦

Codes ⬦

Tutorials ⬦

Teaching ⬦

Positions ⬦

Student Projects ⬦

Blog ⬦

People ⬦

HowTo ◆

Contact ⬦



Google Scholar GitHub Mathworks

YouTube Email Location



Contents:


How to Install TensorFlow GPU?

Here's a step-by-step tutorial on how to install TensorFlow GPU using Conda:

Step 1: Install Anaconda or Miniconda

Step 2: Create a new Conda environment

conda create --name tf_gpu python=3.9
conda activate tf_gpu

Step 3: Install TensorFlow GPU

conda install tensorflow-gpu

Step 4: Verify the installation

python
import tensorflow as tf 
print(tf.__version__)
print(tf.test.is_gpu_available())

If TensorFlow GPU is properly installed and the GPU is recognized, it should output True.

That's it! You have successfully installed TensorFlow GPU using Conda. Remember to activate the Conda environment (conda activate tf_gpu) whenever you want to use TensorFlow GPU in your projects.

Note: Make sure you have a compatible NVIDIA GPU and the appropriate GPU drivers installed on your system before installing TensorFlow GPU.


How to convert an image sequence into a 3D array in MATLAB?

  1. Load the image sequence:
    • Place all the images from the sequence in a single folder.
    • In MATLAB, set the current working directory to the folder containing the images using the cd command:
    • cd('path/to/your/image/folder')
    • Get a list of all the image files in the folder using the dir command:
    • files = dir('*.jpg'); % Replace '*.jpg' with the appropriate image file extension
  2. Determine the image dimensions:
    • Read the first image and convert it to grayscale using the imread and rgb2gray functions:
    • firstImage = rgb2gray(imread(files(1).name)); [height, width] = size(firstImage);
    • The height and width variables will store the dimensions of the grayscale images.
  3. Preallocate the 3D array:
    • Create a 3D array to store the grayscale image sequence using the zeros function:
    • numFrames = length(files); imageArray = zeros(height, width, numFrames, 'uint8');
    • The numFrames variable represents the number of images in the sequence.
  4. Load the images into the 3D array:
    • Use a loop to iterate over the image files, convert them to grayscale, and store them in the 3D array:
    • for i = 1:numFrames
       imageArray(:,:,i) = rgb2gray(imread(files(i).name)); end
    • Each image is loaded using the imread function, converted to grayscale using rgb2gray, and stored in the corresponding position in the imageArray.
  5. Verify the 3D array:
    • Display the dimensions of the resulting 3D array:
    • size(imageArray)
    • You can also visualize individual frames from the 3D array using the imshow function:
    • imshow(imageArray(:,:,1));
    • Replace 1 with the desired frame number to display different frames.
  6. Save the 3D array as a MAT file:
    • Use the save function to save the 3D array as a MAT file:
    • save('imageSequence.mat', 'imageArray');
    • The 'imageSequence.mat' argument specifies the filename of the MAT file, and 'imageArray' is the variable name of the 3D array to be saved.


How to find the image spatial resolution?

Here's how to calculate the spatial resolution of an image using Windows Paint:

Step 1: Open the image in Windows Paint

Step 2: Locate the scale bar in the image

Step 3: Measure the length of the scale bar in pixels

Step 4: Calculate the spatial resolution

Step 5: Interpret the spatial resolution

By following these steps, you can easily calculate the spatial resolution of an image using Windows Paint and gain a better understanding of the physical scale represented in the image.


How to locally run Colab notebooks (seamlessly)?

Here's how to run notebooks seamlessly on Colab or locally:

 

Step 1: Set up Google Drive

 

Step 2: Mount Google Drive in Colab (if using Colab)

 

Step 3: Set up the notebook

  

This code snippet automatically detects whether the notebook is running on Colab or locally by checking for the existence of the "C:" drive. It sets the colab variable accordingly and adjusts the prepath variable to the appropriate path for accessing the notebook files.

 


How to create publication-quality plots in LaTeX via MATLAB?

Here's how to have (very!) high quality plots in Latex:

 

Step 1: Draw the plots in MATLAB and copy the figures with metadata

 

Step 2: Paste the plot in PowerPoint and add final touches

 

Step 3: Save the plot as a PDF

 

Step 4: Crop the PDF automatically using the pdfcropmargin package in Python

 

Step 5: Insert the cropped plot into your LaTeX document

 

Step 6: (Optional) Define a counter in LaTeX to automatically increment the page number

 

By following these steps, you can ensure that your plots in LaTeX are of very high quality, with the added convenience of automating the cropping and insertion process.