【交互式阈值二进制图像】采用彩色或单色图像通过交互/手动方式阈值单色图像或彩色图像的单个色带研究(Matlab代码实现)

本文主要是介绍【交互式阈值二进制图像】采用彩色或单色图像通过交互/手动方式阈值单色图像或彩色图像的单个色带研究(Matlab代码实现),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

【交互式阈值二进制图像】采用彩色或单色图像通过交互/手动方式阈值单色图像或彩色图像的单个色带

本文介绍了一种交互式阈值二进制图像的方法。该方法可以应用于彩色或单色图像,并且允许用户通过滑块的方式以交互/手动的方式设置图像的阈值范围。

阈值图像是一种二进制图像,可以用作其他图像的遮罩图像。在阈值范围内的像素将在中间图像中显示为二进制图像(黑/白),而原始图像的像素将在左侧图像中显示为遮罩(灰度或彩色)。用户可以通过设置最大和最小阈值来调整阈值范围,从而实现对图像的二值化处理。

该方法的输入包括要开始的低阈值和高阈值,以及图像文件名或图像矩阵。可以处理的图像类型包括整数类型(如uint8、uint16等)和浮点类型(如单精度、双精度)。

该方法的输出包括阈值范围和用于选择阈值的最后一个色带。用户可以根据自己的需求选择合适的阈值范围,并通过调整滑块来实现图像的二值化处理。

通过使用交互式阈值二进制图像的方法,用户可以更加灵活地处理彩色或单色图像,并根据需要调整阈值范围,从而得到满足自己需求的二值化图像。该方法具有简单、直观的操作界面,适用于各种图像处理应用场景。

📚2 运行结果

部分代码:

% Read in a standard MATLAB gray scale demo image.
folder = fileparts(which('cameraman.tif')); % Determine where demo folder is (works with all versions).
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')% File doesn't exist.  Try it without the folder.% It might be able to find it in a folder off the search path.fullFileName = baseFileName;if ~exist(fullFileName, 'file')% Can't find it off the search path either.errorMessage = sprintf('Error: cannot find demo image %s', baseFileName);uiwait(msgbox(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, 3, 1);
imshow(grayImage, []);
axis off;
title('Original Grayscale Image', 'FontSize', fontSize);
% Set up figure properties.
set(gcf, 'Name', 'Thresholding Demo by ImageAnalyst', 'NumberTitle', 'off') 
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full screen.message = sprintf('Thresholding demo by ImageAnalyst.\n\nDo you want to use an integer image or a floating point image?');
button = questdlg(message, 'Image Type?', 'Integer', 'Floating Point', 'Cancel', 'Integer');
drawnow;	% Refresh screen to get rid of dialog box remnants.
if strcmpi(button, 'Cancel')close(gcf);	% Get rid of window.return;
end
if strcmpi(button, 'Floating Point')% Convert to double in the range -5000 to + 15000% Get input min and max.minGL = double(min(grayImage(:)));maxGL = double(max(grayImage(:)));% Scale the imageimageToThreshold = 20000 * mat2gray(grayImage) - 5000;% Verify themminDblGL = min(imageToThreshold(:));maxDblGL = max(imageToThreshold(:));fprintf('Before scaling, min gray level = %.1f, max gray level = %.1f\nAfter scaling,  min gray level = %.1f, max gray level = %.1f\n', ...minGL, maxGL, minDblGL, maxDblGL);startingLowThreshold = -800;startingHighThreshold = 10400;% Get the histogram[pixelCount, grayLevels] = hist(imageToThreshold(:), 300);subplot(2, 3, 2); bar(grayLevels, pixelCount, 'BarWidth', 1, 'FaceColor', 'b');title('Histogram of Original Double Image', 'FontSize', fontSize);xlim([minDblGL, maxDblGL]); % Scale x axis manually.

% Read in a standard MATLAB gray scale demo image.
folder = fileparts(which('cameraman.tif')); % Determine where demo folder is (works with all versions).
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
    % File doesn't exist.  Try it without the folder.
    % It might be able to find it in a folder off the search path.
    fullFileName = baseFileName;
    if ~exist(fullFileName, 'file')
        % Can't find it off the search path either.
        errorMessage = sprintf('Error: cannot find demo image %s', baseFileName);
        uiwait(msgbox(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, 3, 1);
imshow(grayImage, []);
axis off;
title('Original Grayscale Image', 'FontSize', fontSize);
% Set up figure properties.
set(gcf, 'Name', 'Thresholding Demo by ImageAnalyst', 'NumberTitle', 'off') 
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full screen.

message = sprintf('Thresholding demo by ImageAnalyst.\n\nDo you want to use an integer image or a floating point image?');
button = questdlg(message, 'Image Type?', 'Integer', 'Floating Point', 'Cancel', 'Integer');
drawnow;    % Refresh screen to get rid of dialog box remnants.
if strcmpi(button, 'Cancel')
    close(gcf);    % Get rid of window.
    return;
end
if strcmpi(button, 'Floating Point')
    % Convert to double in the range -5000 to + 15000
    % Get input min and max.
    minGL = double(min(grayImage(:)));
    maxGL = double(max(grayImage(:)));
    % Scale the image
    imageToThreshold = 20000 * mat2gray(grayImage) - 5000;
    % Verify them
    minDblGL = min(imageToThreshold(:));
    maxDblGL = max(imageToThreshold(:));
    fprintf('Before scaling, min gray level = %.1f, max gray level = %.1f\nAfter scaling,  min gray level = %.1f, max gray level = %.1f\n', ...
        minGL, maxGL, minDblGL, maxDblGL);
    startingLowThreshold = -800;
    startingHighThreshold = 10400;
    % Get the histogram
    [pixelCount, grayLevels] = hist(imageToThreshold(:), 300);
    subplot(2, 3, 2); 
    bar(grayLevels, pixelCount, 'BarWidth', 1, 'FaceColor', 'b');
    title('Histogram of Original Double Image', 'FontSize', fontSize);
    xlim([minDblGL, maxDblGL]); % Scale x axis manually.

🎉3 参考文献

文章中一些内容引自网络,会注明出处或引用为参考文献,难免有未尽之处,如有不妥,请随时联系删除。

[1]龙建武,申铉京,陈海鹏.基于图像区域的交互式文本图像阈值分割算法[J].计算机研究与发展, 2012, 49(7):12.DOI:CNKI:SUN:JFYZ.0.2012-07-005.

[2]龙建武申铉京陈海鹏.基于图像区域的交互式文本图像阈值分割算法[J].计算机研究与发展, 2012, 49(7):1420-1431.

[3]兰红.多阈值优化的交互式医学图像分割方法[J].计算机科学, 2013, 40(9):4.DOI:10.3969/j.issn.1002-137X.2013.09.066.

🌈4 Matlab代码实现

这篇关于【交互式阈值二进制图像】采用彩色或单色图像通过交互/手动方式阈值单色图像或彩色图像的单个色带研究(Matlab代码实现)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/180778

相关文章

Java实现检查多个时间段是否有重合

《Java实现检查多个时间段是否有重合》这篇文章主要为大家详细介绍了如何使用Java实现检查多个时间段是否有重合,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录流程概述步骤详解China编程步骤1:定义时间段类步骤2:添加时间段步骤3:检查时间段是否有重合步骤4:输出结果示例代码结语作

使用C++实现链表元素的反转

《使用C++实现链表元素的反转》反转链表是链表操作中一个经典的问题,也是面试中常见的考题,本文将从思路到实现一步步地讲解如何实现链表的反转,帮助初学者理解这一操作,我们将使用C++代码演示具体实现,同... 目录问题定义思路分析代码实现带头节点的链表代码讲解其他实现方式时间和空间复杂度分析总结问题定义给定

Java覆盖第三方jar包中的某一个类的实现方法

《Java覆盖第三方jar包中的某一个类的实现方法》在我们日常的开发中,经常需要使用第三方的jar包,有时候我们会发现第三方的jar包中的某一个类有问题,或者我们需要定制化修改其中的逻辑,那么应该如何... 目录一、需求描述二、示例描述三、操作步骤四、验证结果五、实现原理一、需求描述需求描述如下:需要在

Debezium 与 Apache Kafka 的集成方式步骤详解

《Debezium与ApacheKafka的集成方式步骤详解》本文详细介绍了如何将Debezium与ApacheKafka集成,包括集成概述、步骤、注意事项等,通过KafkaConnect,D... 目录一、集成概述二、集成步骤1. 准备 Kafka 环境2. 配置 Kafka Connect3. 安装 D

如何使用Java实现请求deepseek

《如何使用Java实现请求deepseek》这篇文章主要为大家详细介绍了如何使用Java实现请求deepseek功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1.deepseek的api创建2.Java实现请求deepseek2.1 pom文件2.2 json转化文件2.2

Java调用DeepSeek API的最佳实践及详细代码示例

《Java调用DeepSeekAPI的最佳实践及详细代码示例》:本文主要介绍如何使用Java调用DeepSeekAPI,包括获取API密钥、添加HTTP客户端依赖、创建HTTP请求、处理响应、... 目录1. 获取API密钥2. 添加HTTP客户端依赖3. 创建HTTP请求4. 处理响应5. 错误处理6.

python使用fastapi实现多语言国际化的操作指南

《python使用fastapi实现多语言国际化的操作指南》本文介绍了使用Python和FastAPI实现多语言国际化的操作指南,包括多语言架构技术栈、翻译管理、前端本地化、语言切换机制以及常见陷阱和... 目录多语言国际化实现指南项目多语言架构技术栈目录结构翻译工作流1. 翻译数据存储2. 翻译生成脚本

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

如何通过Python实现一个消息队列

《如何通过Python实现一个消息队列》这篇文章主要为大家详细介绍了如何通过Python实现一个简单的消息队列,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录如何通过 python 实现消息队列如何把 http 请求放在队列中执行1. 使用 queue.Queue 和 reque

Python如何实现PDF隐私信息检测

《Python如何实现PDF隐私信息检测》随着越来越多的个人信息以电子形式存储和传输,确保这些信息的安全至关重要,本文将介绍如何使用Python检测PDF文件中的隐私信息,需要的可以参考下... 目录项目背景技术栈代码解析功能说明运行结php果在当今,数据隐私保护变得尤为重要。随着越来越多的个人信息以电子形