【交互式阈值二进制图像】采用彩色或单色图像通过交互/手动方式阈值单色图像或彩色图像的单个色带研究(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

相关文章

Spring Boot 实现 IP 限流的原理、实践与利弊解析

《SpringBoot实现IP限流的原理、实践与利弊解析》在SpringBoot中实现IP限流是一种简单而有效的方式来保障系统的稳定性和可用性,本文给大家介绍SpringBoot实现IP限... 目录一、引言二、IP 限流原理2.1 令牌桶算法2.2 漏桶算法三、使用场景3.1 防止恶意攻击3.2 控制资源

Python如何去除图片干扰代码示例

《Python如何去除图片干扰代码示例》图片降噪是一个广泛应用于图像处理的技术,可以提高图像质量和相关应用的效果,:本文主要介绍Python如何去除图片干扰的相关资料,文中通过代码介绍的非常详细,... 目录一、噪声去除1. 高斯噪声(像素值正态分布扰动)2. 椒盐噪声(随机黑白像素点)3. 复杂噪声(如伪

springboot下载接口限速功能实现

《springboot下载接口限速功能实现》通过Redis统计并发数动态调整每个用户带宽,核心逻辑为每秒读取并发送限定数据量,防止单用户占用过多资源,确保整体下载均衡且高效,本文给大家介绍spring... 目录 一、整体目标 二、涉及的主要类/方法✅ 三、核心流程图解(简化) 四、关键代码详解1️⃣ 设置

Java Spring ApplicationEvent 代码示例解析

《JavaSpringApplicationEvent代码示例解析》本文解析了Spring事件机制,涵盖核心概念(发布-订阅/观察者模式)、代码实现(事件定义、发布、监听)及高级应用(异步处理、... 目录一、Spring 事件机制核心概念1. 事件驱动架构模型2. 核心组件二、代码示例解析1. 事件定义

Nginx 配置跨域的实现及常见问题解决

《Nginx配置跨域的实现及常见问题解决》本文主要介绍了Nginx配置跨域的实现及常见问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来... 目录1. 跨域1.1 同源策略1.2 跨域资源共享(CORS)2. Nginx 配置跨域的场景2.1

Python中提取文件名扩展名的多种方法实现

《Python中提取文件名扩展名的多种方法实现》在Python编程中,经常会遇到需要从文件名中提取扩展名的场景,Python提供了多种方法来实现这一功能,不同方法适用于不同的场景和需求,包括os.pa... 目录技术背景实现步骤方法一:使用os.path.splitext方法二:使用pathlib模块方法三

CSS实现元素撑满剩余空间的五种方法

《CSS实现元素撑满剩余空间的五种方法》在日常开发中,我们经常需要让某个元素占据容器的剩余空间,本文将介绍5种不同的方法来实现这个需求,并分析各种方法的优缺点,感兴趣的朋友一起看看吧... css实现元素撑满剩余空间的5种方法 在日常开发中,我们经常需要让某个元素占据容器的剩余空间。这是一个常见的布局需求

HTML5 getUserMedia API网页录音实现指南示例小结

《HTML5getUserMediaAPI网页录音实现指南示例小结》本教程将指导你如何利用这一API,结合WebAudioAPI,实现网页录音功能,从获取音频流到处理和保存录音,整个过程将逐步... 目录1. html5 getUserMedia API简介1.1 API概念与历史1.2 功能与优势1.3

gitlab安装及邮箱配置和常用使用方式

《gitlab安装及邮箱配置和常用使用方式》:本文主要介绍gitlab安装及邮箱配置和常用使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装GitLab2.配置GitLab邮件服务3.GitLab的账号注册邮箱验证及其分组4.gitlab分支和标签的

Java实现删除文件中的指定内容

《Java实现删除文件中的指定内容》在日常开发中,经常需要对文本文件进行批量处理,其中,删除文件中指定内容是最常见的需求之一,下面我们就来看看如何使用java实现删除文件中的指定内容吧... 目录1. 项目背景详细介绍2. 项目需求详细介绍2.1 功能需求2.2 非功能需求3. 相关技术详细介绍3.1 Ja