How do you combine multiple sliders into one on Matlab?
I have 3 different sliders doing 3 different things and I’m trying to have all the things being done to it in one function at the same time. I’ve tried many different things and I still don’t know how. If anybody could provide some insight that would be greatly appreciated.
% Load the Image
inputImage = imread("funny-animals-190-02.jpg");
% Display original image
imshow(inputImage)
title(‘Original Image’)
conslider = uislider;
conslider.Position = [150 20 300 3];
conslider.Limits = [0 2];
conslider.Value = 1;
conslider.MajorTicks = [0 0.5 1 1.5 2];
conslider.ValueChangedFcn = @updateImage;
function updateImage(conslider,~)
contrastFactor = conslider.Value;
inputImage = imread("funny-animals-190-02.jpg");
hsvImage = rgb2hsv(inputImage);
outputImage = hsv2rgb(hsvImage);
% Do the stuff for contrast here
outputImage = imadjust(outputImage, [], [], contrastFactor);
% Display the updated image
imshow(outputImage);
title([‘contrastFactor: ‘ num2str(contrastFactor)]);
end
% Load the Image
inputImage = imread("funny-animals-190-02.jpg");
% Display original image
imshow(inputImage)
title(‘Original Image’)
% Developing a slider to adjust the saturation
satslider = uislider;
satslider.Position = [150 20 300 3];
satslider.Limits = [0 2];
satslider.Value = 1;
satslider.MajorTicks = [0 0.5 1 1.5 2];
satslider.ValueChangedFcn = @updateImage
function updateImage(satslider,~)
% Read the current saturation value from the slider
saturationFactor = satslider.Value;
% Convert the image to HSV color space
inputImage = imread("funny-animals-190-02.jpg");
hsvImage = rgb2hsv(inputImage);
% Update the saturation (S)
hsvImage(:, :, 2) = hsvImage(:, :, 2) * saturationFactor;
% Convert the modified image back to RGB color space
outputImage = hsv2rgb(hsvImage);
% Do the stuff for contrast here
% Display the updated image
imshow(outputImage);
title([‘Saturation Factor: ‘ num2str(saturationFactor)]);
end
% Load the Image
inputImage = imread("funny-animals-190-02.jpg");
% Display original image
imshow(inputImage)
title(‘Original Image’)
sharpslider = uislider;
sharpslider.Position = [150 20 300 3];
sharpslider.Limits = [0 2];
sharpslider.Value = 1;
sharpslider.MajorTicks = [0 0.5 1 1.5 2];
sharpslider.ValueChangedFcn = @updateImage;
function updateImage(sharpslider,~)
sharpenFactor = sharpslider.Value;
inputImage = imread("funny-animals-190-02.jpg");
hsvImage = rgb2hsv(inputImage);
outputImage = hsv2rgb(hsvImage);
% Do the stuff for contrast here
outputImage = imsharpen(inputImage, ‘Amount’, sharpenFactor);
% Display the updated image
imshow(outputImage);
title([‘sharpenFactor: ‘ num2str(sharpenFactor)]);
endI have 3 different sliders doing 3 different things and I’m trying to have all the things being done to it in one function at the same time. I’ve tried many different things and I still don’t know how. If anybody could provide some insight that would be greatly appreciated.
% Load the Image
inputImage = imread("funny-animals-190-02.jpg");
% Display original image
imshow(inputImage)
title(‘Original Image’)
conslider = uislider;
conslider.Position = [150 20 300 3];
conslider.Limits = [0 2];
conslider.Value = 1;
conslider.MajorTicks = [0 0.5 1 1.5 2];
conslider.ValueChangedFcn = @updateImage;
function updateImage(conslider,~)
contrastFactor = conslider.Value;
inputImage = imread("funny-animals-190-02.jpg");
hsvImage = rgb2hsv(inputImage);
outputImage = hsv2rgb(hsvImage);
% Do the stuff for contrast here
outputImage = imadjust(outputImage, [], [], contrastFactor);
% Display the updated image
imshow(outputImage);
title([‘contrastFactor: ‘ num2str(contrastFactor)]);
end
% Load the Image
inputImage = imread("funny-animals-190-02.jpg");
% Display original image
imshow(inputImage)
title(‘Original Image’)
% Developing a slider to adjust the saturation
satslider = uislider;
satslider.Position = [150 20 300 3];
satslider.Limits = [0 2];
satslider.Value = 1;
satslider.MajorTicks = [0 0.5 1 1.5 2];
satslider.ValueChangedFcn = @updateImage
function updateImage(satslider,~)
% Read the current saturation value from the slider
saturationFactor = satslider.Value;
% Convert the image to HSV color space
inputImage = imread("funny-animals-190-02.jpg");
hsvImage = rgb2hsv(inputImage);
% Update the saturation (S)
hsvImage(:, :, 2) = hsvImage(:, :, 2) * saturationFactor;
% Convert the modified image back to RGB color space
outputImage = hsv2rgb(hsvImage);
% Do the stuff for contrast here
% Display the updated image
imshow(outputImage);
title([‘Saturation Factor: ‘ num2str(saturationFactor)]);
end
% Load the Image
inputImage = imread("funny-animals-190-02.jpg");
% Display original image
imshow(inputImage)
title(‘Original Image’)
sharpslider = uislider;
sharpslider.Position = [150 20 300 3];
sharpslider.Limits = [0 2];
sharpslider.Value = 1;
sharpslider.MajorTicks = [0 0.5 1 1.5 2];
sharpslider.ValueChangedFcn = @updateImage;
function updateImage(sharpslider,~)
sharpenFactor = sharpslider.Value;
inputImage = imread("funny-animals-190-02.jpg");
hsvImage = rgb2hsv(inputImage);
outputImage = hsv2rgb(hsvImage);
% Do the stuff for contrast here
outputImage = imsharpen(inputImage, ‘Amount’, sharpenFactor);
% Display the updated image
imshow(outputImage);
title([‘sharpenFactor: ‘ num2str(sharpenFactor)]);
end I have 3 different sliders doing 3 different things and I’m trying to have all the things being done to it in one function at the same time. I’ve tried many different things and I still don’t know how. If anybody could provide some insight that would be greatly appreciated.
% Load the Image
inputImage = imread("funny-animals-190-02.jpg");
% Display original image
imshow(inputImage)
title(‘Original Image’)
conslider = uislider;
conslider.Position = [150 20 300 3];
conslider.Limits = [0 2];
conslider.Value = 1;
conslider.MajorTicks = [0 0.5 1 1.5 2];
conslider.ValueChangedFcn = @updateImage;
function updateImage(conslider,~)
contrastFactor = conslider.Value;
inputImage = imread("funny-animals-190-02.jpg");
hsvImage = rgb2hsv(inputImage);
outputImage = hsv2rgb(hsvImage);
% Do the stuff for contrast here
outputImage = imadjust(outputImage, [], [], contrastFactor);
% Display the updated image
imshow(outputImage);
title([‘contrastFactor: ‘ num2str(contrastFactor)]);
end
% Load the Image
inputImage = imread("funny-animals-190-02.jpg");
% Display original image
imshow(inputImage)
title(‘Original Image’)
% Developing a slider to adjust the saturation
satslider = uislider;
satslider.Position = [150 20 300 3];
satslider.Limits = [0 2];
satslider.Value = 1;
satslider.MajorTicks = [0 0.5 1 1.5 2];
satslider.ValueChangedFcn = @updateImage
function updateImage(satslider,~)
% Read the current saturation value from the slider
saturationFactor = satslider.Value;
% Convert the image to HSV color space
inputImage = imread("funny-animals-190-02.jpg");
hsvImage = rgb2hsv(inputImage);
% Update the saturation (S)
hsvImage(:, :, 2) = hsvImage(:, :, 2) * saturationFactor;
% Convert the modified image back to RGB color space
outputImage = hsv2rgb(hsvImage);
% Do the stuff for contrast here
% Display the updated image
imshow(outputImage);
title([‘Saturation Factor: ‘ num2str(saturationFactor)]);
end
% Load the Image
inputImage = imread("funny-animals-190-02.jpg");
% Display original image
imshow(inputImage)
title(‘Original Image’)
sharpslider = uislider;
sharpslider.Position = [150 20 300 3];
sharpslider.Limits = [0 2];
sharpslider.Value = 1;
sharpslider.MajorTicks = [0 0.5 1 1.5 2];
sharpslider.ValueChangedFcn = @updateImage;
function updateImage(sharpslider,~)
sharpenFactor = sharpslider.Value;
inputImage = imread("funny-animals-190-02.jpg");
hsvImage = rgb2hsv(inputImage);
outputImage = hsv2rgb(hsvImage);
% Do the stuff for contrast here
outputImage = imsharpen(inputImage, ‘Amount’, sharpenFactor);
% Display the updated image
imshow(outputImage);
title([‘sharpenFactor: ‘ num2str(sharpenFactor)]);
end sliders MATLAB Answers — New Questions