Converting a .raw image to a .jpg before calculating the intensity profile is not advisable because JPEG is a lossy format that compresses the image, losing detail and accuracy. It's best to work directly with the raw data to maintain accuracy.
To read a .raw image you can simply use the fopen and fread and to calculate the intensity profile you can use the improfile function (https://www.mathworks.com/help/images/ref/improfile.html).
To calculate the intensity profile of a .raw image in MATLAB, first read the image data using fopen and fread. Reshape the data into a matrix and then sum the pixel values along the desired axis (e.g., rows for horizontal profile). Use plot to visualize the intensity profile.