# MATLAB: How to draw a slider for image comparison

image processing

I'd like to draw a circle for a slider like this (https://www.w3schools.com/howto/howto_js_image_comparison.asp). I can slide and compare the images, however, I can't make a circle like the one they made it so I can hold the mouse inside that circle and adjust the slider.
Here is the code for image comparison.
``clcclear all close all im_left = im2double(imread('pears.png')); % opening two example imagesim_right = im2double(imread('peacock.jpg'));im_right = imresize(im_right, size(im_left, [1 2])); % making the dimensions equalf = figure();ax = axes('Units', 'pixels');imshow(im_left);hold(ax);im_handle = imshow(im_right);im_handle.AlphaData = zeros(size(im_left, [1 2]));axes_pos = cumsum(ax.Position([1 3]));f.WindowButtonMotionFcn = {@cb,  size(im_left,2), im_handle, axes_pos};function cb(obj, ~, im_width, im_handle, axes_pos)    x_pos = obj.CurrentPoint(1);    if x_pos > axes_pos(1) && x_pos < axes_pos(2)        left_cols = floor(floor(x_pos - axes_pos(1))/diff(axes_pos) * im_width);        im_handle.AlphaData(:, 1:left_cols) = 0;        im_handle.AlphaData(:, left_cols+1:end) = 1;    endend``

#### Best Answer

• I understand you want to make slider on two images for comaprision. But nowhere you used Css property which is present in the link( https://www.w3schools.com/howto/howto_js_image_comparison.asp ) you provided. You can do this by using importing mlreportgen.dom.* and then defining yu css properties.
I am attaching the link for how you can define your css properties.
Or
The latest Matlab GUI (created using the App Designer tool or the uifigure function) is based on HTML, JavaScript and CSS - not on Java Swing. You can check here: