Effacer les filtres
Effacer les filtres

Obtaining the curve of highest intensity ?

2 vues (au cours des 30 derniers jours)
nick.x101
nick.x101 le 28 Mar 2016
Commenté : Image Analyst le 28 Mar 2016
I am currently trying to determine the curve of highest intensity from the attached image which should be the line along the centerline of the bright path. Also is it possible to create a surface of revolution from this in matlab or get the equation of the curve in 2d? A sample of the code is shown below.
% Read in a image.
folder = 'C:\Users\User\Documents\MATLAB\';
baseFileName = 'Test_28.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows, columns, numberOfColorBands] = size(grayImage);
for col = 1 : columns
[maxValue(col), row(col)] = max(grayImage(:, col));
end
plot(row,maxValue(1,:), 'r+', 'LineWidth', 2, 'MarkerSize', 2)
  1 commentaire
Image Analyst
Image Analyst le 28 Mar 2016
You forgot to attach the image.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 28 Mar 2016
Try this instead:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Read in a image.
folder = pwd;
baseFileName = 'Test_3.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
subplot(1,2,1);
imshow(grayImage, []);
title('Original Image', 'fontSize', fontSize);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows, columns, numberOfColorBands] = size(grayImage);
if numberOfColorBands > 1
% Take red channel because it has the highest contrast.
grayImage = grayImage(:, :, 1);
end
subplot(1,2,2);
imshow(grayImage, []);
title('Gray Scale Image', 'fontSize', fontSize);
for col = 1 : columns
[maxValue(col), row(col)] = max(grayImage(:, col));
end
hold on;
plot(1 : columns, row, 'r+', 'LineWidth', 2, 'MarkerSize', 2)
As you can see, your algorithm is not very good.
  2 commentaires
nick.x101
nick.x101 le 28 Mar 2016
Modifié(e) : nick.x101 le 28 Mar 2016
Thanks Image Analyst. I'll try apply a threshold to the image and see if it helps but is there any way around this large scatter ? Like a more suitable method ?
Image Analyst
Image Analyst le 28 Mar 2016
What kind of image is this? Is it fluorescence or radiography? Or is it something else? If you can get a black shot without the bright curve, so that you just have the Gaussian hump in the middle, then you can do background subtraction (for fluorescence or radiography) or background division (most everything else) to flatten the image and get rid of that bright hump that is causing all the problems. Then you can try again to threshold. You might also try some denoising methods like blurring, median filter, closing, etc. to try to get a nice solid curve that can be thresholded.
If you can't get a background image, let me know and there are some things you can try to create a background image from your exiting image, such as modeling one from known background areas, which you'll need to at least make a guess at identifying first.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Biomedical Imaging dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by