What to do if insertText doesn't work, but there are no error codes?
Show older comments
I'm trying to add text to an image I have but the insertText function isn't working. No errors show up when I run the Matlab script, but neither does the text. Here is what I have:
t = Tiff('TEmp.tiff', 'r'); % Create .tiff object
figure
imageData = read(t); % Create image data
imageData = imageData(:,:,1:3); %remove redundant data
imshow(imageData) % Show the image in a figure
hold on
% Plot a line.
maxy = 300;
a=[0 maxy];
b = [0 maxy];
plot(a, b, 'b')
hold on
RGB = insertText(imageData,[1 150],'Hello','FontSize',30,'BoxColor','red')
When I run this, the line found using plot(a,b) shows up, but the phrase 'Hello' does not. Any idea why this isn't working? I have the Computer Vision System Toolbox installed.
Accepted Answer
More Answers (1)
yes,sir,may be use text to add text object on figure,or use insertText to generate a new image and imshow by another figure,such as
clc; clear all; close all;
t = Tiff('example.tif', 'r'); % Create .tiff object
figure
imageData = read(t); % Create image data
imageData = imageData(:,:,1:3); %remove redundant data
imshow(imageData) % Show the image in a figure
hold on
% Plot a line.
maxy = 300;
a=[0 maxy];
b = [0 maxy];
plot(a, b, 'b')
hold on
RGB = insertText(imageData,[1 150],'Hello','FontSize',30,'BoxColor','red');
h = text(1,150,'Hello','FontSize',30,'Color','red','EdgeColor','red');
figure; imshow(RGB, []);
Categories
Find more on Computer Vision Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


