Infrared images threshold

3 visualizaciones (últimos 30 días)
Syahrul Niezam
Syahrul Niezam el 14 de Nov. de 2011
Comentada: Image Analyst el 12 de Jul. de 2022
Hello. I'm doing assignment project using infrared images. I would like to segment the images into certain regions using threshold method. I tried searching in the internet, and found the Otsu's method. I'm not sure it can be applied in infrared images or not. Is there other methods beside that?
Thank you.

Respuestas (4)

Walter Roberson
Walter Roberson el 14 de Nov. de 2011
Yes, Otsu's method is valid for infrared images; you can use the graythresh routine if you have access to that toolbox.
However, as is the case with all automatic thresholding routines, the routines are not sensitive to context, and have no idea what is "important" to the problem at hand. With infrared, sometimes you are interested in the warm spots and sometimes you are interested in the cold spots, and sometimes you are interested in spots that are "warmish" but cooler than their surroundings (e.g., detecting an living (warmish) obstruction against a hot building against a cold sky). A routine such as Otsu's is not going to know what is important.
  4 comentarios
Syahrul Niezam
Syahrul Niezam el 27 de En. de 2012
I'm sorry. this is the correct one; my codes for segmentation image into four regions by threshold values.
a = imread('image1_069.jpg');
b = unit8(a<90);% In this order!
b(a >= 110) = 180;
b(a >= 150) = 200;
b(a >= 200) = 255;
btw, what is quantization.
Walter Roberson
Walter Roberson el 28 de En. de 2012
unit8() is not defined. You probably mean uint8()
http://en.wikipedia.org/wiki/Quantization
"Quantization is the procedure of constraining something from a relatively large or continuous set of values (such as the real numbers) to a relatively small discrete set (such as the integers)"

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 14 de Nov. de 2011
What Walter says is true. Often I encounter histograms that are like skewed Gaussians, instead of a nice well separated pair of Gaussians like you'd want to represent foreground and background. In cases like that (which are frequent with me) I prefer the triangle method: http://www.mathworks.com/matlabcentral/fileexchange/28047-gray-image-thresholding-using-the-triangle-method It seems to pick a better threshold than Otsu where you have more of a blending of foreground and background pixels rather than a nice bimodal histogram. Often you get some first shot at your objects via thresholding and then you have to further narrow down objects to valid foreground objects via things like filtering them based on their shape or area, etc. So often detecting foreground by simply thresholding is not enough - you need more than that.
  8 comentarios
Syahrul Niezam
Syahrul Niezam el 28 de En. de 2012
I had tried executing the triangle_th codes in given link with this image;
http://i42.tinypic.com/bdplk1.jpg
and then this error appeared on command window:
??? Input argument "lehisto" is undefined.
Error in ==> th2 at 30
[h,xmax]=max(lehisto);
I had also executed the Demo_triangle_th codes and this error appeared on command window:
??? Undefined function or method 'triangle_th' for input arguments of type 'double'.
Error in ==> th at 11
[level]=triangle_th(lehisto,256);
I don't know what lehisto means. Is it related with the image used?
Thank you a lot in advance.
Image Analyst
Image Analyst el 28 de En. de 2012
Come on, did you actually pass lehisto into the function? No, you didn't. I guess you could benefit from a demo where I explicitly do it for you. See my other answer.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 28 de En. de 2012
% Demo to do triangle thresholding of an image.
% By ImageAnalyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 14;
% Read in a standard MATLAB gray scale demo image.
folder = 'C:\Users\Syahrul\Documents\Temporary';
baseFileName = 'bdplk1.jpg';
fullFileName = fullfile(folder, baseFileName);
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', 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);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
axis on;
% Let's compute and display the histogram.
[pixelCount grayLevels] = imhist(grayImage);
subplot(2, 2, 2);
bar(pixelCount);
title('Histogram of original image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
grid on;
[level]=triangle_th(pixelCount, 256)
thresholdvalue = int32(level * intmax(class(grayImage)));
binaryImage = grayImage > level * 255;
% Display the image.
subplot(2, 2, 3);
imshow(binaryImage, []);
caption = sprintf('Binarized at %d', thresholdvalue);
title(caption, 'FontSize', fontSize);
  5 comentarios
Mohsen
Mohsen el 12 de Jul. de 2022
thank you , I past it.
but another error happens :
""" Error using images.internal.imageDisplayValidateParams>validateCData (line 119)
If input is logical (binary), it must be two-dimensional.
Error in images.internal.imageDisplayValidateParams (line 27)
common_args.CData = validateCData(common_args.CData,image_type);
Error in images.internal.imageDisplayParseInputs (line 78)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 245)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in process (line 52)
imshow(binaryImage, []); """
Image Analyst
Image Analyst el 12 de Jul. de 2022
Like it says, there is some problem with binaryImage. It's not a regular gray scale, color, indexed, or binary image. What is it?
whos binaryImage
If you have more trouble, start a whole new discussion thread and attach your image and code after reading this:

Iniciar sesión para comentar.


riadi marta dinata adi
riadi marta dinata adi el 19 de Sept. de 2015
which i know..... matlab cant' read IR on image,this link my be describe how about this... http://www.researchgate.net/post/How_do_you_convert_a_RGB_image_to_an_IR_image_Is_it_possible_using_MATLAB
  1 comentario
Walter Roberson
Walter Roberson el 19 de Sept. de 2015
That link says nothing about MATLAB being unable to read IR images. The link is saying that if what you have is an RGB image then you cannot convert it to an IR image.
Someone posted a link the other day to an interesting article pointing out that certain Canon cameras can have (weak) IR extracted from their RAW images.

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by