Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vedaldi committed Nov 28, 2016
1 parent 3fc226b commit 5417cea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion exercise4.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ function exercise4(varargin)

% Load the sentence
[im,cmap] = imread('data/sentence-lato.png') ;
im = im2single(ind2gray(im,cmap)) ;
if isempty(cmap)
im = im2single(im) ;
else
im = im2single(ind2gray(p,cmap)) ;
end
im = 256 * (im - net.imageMean) ;

% Apply the CNN to the larger image
Expand Down
6 changes: 3 additions & 3 deletions exercise5.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function exercise5()
% obtain and preprocess an image
im = imread('peppers.png') ;
im_ = single(im) ; % note: 255 range
im_ = imresize(im_, net.normalization.imageSize(1:2)) ;
im_ = im_ - net.normalization.averageImage ;
im_ = imresize(im_, net.meta.normalization.imageSize(1:2)) ;
im_ = bsxfun(@minus,im_,net.meta.normalization.averageImage) ;

% run the CNN
res = vl_simplenn(net, im_) ;
Expand All @@ -28,4 +28,4 @@ function exercise5()
[bestScore, best] = max(scores) ;
figure(1) ; clf ; imagesc(im) ; axis image ;
title(sprintf('%s (%d), score %.3f',...
net.classes.description{best}, best, bestScore)) ;
net.meta.classes.description{best}, best, bestScore)) ;
6 changes: 5 additions & 1 deletion extra/packFonts.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ function packFonts()
for i = 1:numel(fonts)
for j = 1:numel(chars)
[p,cmap] = imread(fullfile('extra', 'fonts', fonts{i}, [chars(j) '.png'])) ;
im{i,j} = im2single(ind2gray(p,cmap)) ;
if isempty(cmap)
im{i,j} = im2single(p) ;
else
im{i,j} = im2single(ind2gray(p,cmap)) ;
end
labels{i,j} = j ;
end
end
Expand Down

0 comments on commit 5417cea

Please sign in to comment.