How to subtract a value from passed variable.
Afficher commentaires plus anciens
I am working on a program to read the RGB values and I need the array to start at 0 but currently it starts at 1. Here is the code
sourceimage = '/Users/tapotter/Animations/dblogofilled.gif'; %Pull file to load
numframes = numel(imfinfo(sourceimage)); %Pull the number of frames
fid = fopen('FastLEDAnimation.txt', 'a+'); %Open files to use.
framedelay = imfinfo(sourceimage); % Once only outside the loop
fdelay = framedelay.DelayTime; % Get the frame delay
oldFrame = Inf; % Arbitrary unique value
A = 1;
for iframe = 1:numframes %Go through each frame of the gif
[img, map] = imread(sourceimage, iframe);
rgbimg = im2uint8(ind2rgb(img, map));
crgb = reshape(permute(rgbimg, [3, 1, 2]), 3, []);
Frame = [1:size(crgb, 2); double(crgb)];
changed = any(Frame ~= oldFrame, 1);
oldFrame = Frame;
fprintf(fid, 'leds[(minus(%d, A)].setRGB(%d, %d, %d);\n', Frame(:, changed));
fprintf(fid, '\nFastLED.delay(%d);\nFastLED.show();\n', fdelay);
end
fclose(fid);
fprintf('\nComplete!\n\n');
Here is the line of code I am trying to use to minus the value given from the function,
fprintf(fid, 'leds[(minus(%d, A)].setRGB(%d, %d, %d);\n', Frame(:, changed));
I have tried changing the 'leds[%d}.setRGB(%d, %d, %d);\n' to use the minus, I tried just doing leds[%d - 1}.setRGB(%d, %d, %d);\n' but all it does is either add those words or the -1. How would I minus the value passed? I need it to start at 0 instead of the current "1" it is starting with.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Semantic Segmentation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!