cannot find an algorithm for this - algorithm

The Initial Condition of the problem is like this:
1200 : 480 and 800 : 320
I need an equation(or equations) for changing the value but 320 is fixed.
for example: if change 1200->500 and 800->500 then the equation should be 500:320 and 800:320
example 2 :
1200 : 384 and 1000 : 320
example 3 :
1000 : 400 and 800 : 320
example 4 :
2000 : 640 and 1000 :320

Is this what you are looking for?
numerator = 2.5 * denominator

Related

How to capture windows 10/windows 11 advanced display settings for multiple monitors

I am trying to capture the following displays information connected to my laptop programatically using powershell but I am unable to find a way. This information can be found via the windows GUI at Settings > Display > Advanced Display Information (2 screenshots attached below).
Here's the information I am trying to capture
Display Name: (In this case, display name for internal would be but the external one would be "ASUS VP 228)
Display Resolution: 1680x1050 and 1920x1080 for the 2 displays
Whether it's an internal/external display: True and False
Refresh rate: 60Hz and 60Hz
Here's what I've tried
Get-WmiObject win32_videocontroller
Returns the resolution under parameter VideoModeDescription but even then, it seems to return the value of "Active Signal Resolution" (from the screenshot) below).
Get-WmiObject Win32_Desktopmonitor
DeviceID : DesktopMonitor1
DisplayType :
MonitorManufacturer : (Standard monitor types)
Name : Generic PnP Monitor
ScreenHeight :
ScreenWidth :
Only get output information for 1 out of the 2 monitors and don't get ScreenHeight or ScreenWidth` values.
get-ciminstance -namespace root\wmi -classname wmimonitorbasicdisplayparams
Active : True
DisplayTransferCharacteristic : 120
InstanceName : DISPLAY\IVO8C66\5&462698&0&UID256_0
MaxHorizontalImageSize : 31
MaxVerticalImageSize : 17
SupportedDisplayFeatures : WmiMonitorSupportedDisplayFeatures
VideoInputType : 1
PSComputerName :
Active : True
DisplayTransferCharacteristic : 120
InstanceName : DISPLAY\ACI22C3\5&462698&0&UID265_0
MaxHorizontalImageSize : 48
MaxVerticalImageSize : 27
SupportedDisplayFeatures : WmiMonitorSupportedDisplayFeatures
VideoInputType : 1
PSComputerName
Gives me the correct monitor count but doesn't give me any other information.
I then tried using the DumpEDID tool and it gave me more information but didn't give me current monitor resolution or whether it's an internal display or not.
DumpEDID v1.07
Copyright (c) 2006 - 2018 Nir Sofer
Web site: http://www.nirsoft.net
*****************************************************************
Active : Yes
Registry Key : DISPLAY\ACI22C3\5&462698&0&UID265
Monitor Name : ASUS VP228
Serial Number : G6LMTF155938
Manufacture Week : 26 / 2016
ManufacturerID : 26884 (0x6904)
ProductID : 8899 (0x22C3)
Serial Number (Numeric) : 155938 (0x00026122)
EDID Version : 1.3
Display Gamma : 2.20
Vertical Frequency : 50 - 75 Hz
Horizontal Frequency : 24 - 83 KHz
Maximum Image Size : 48 X 27 cm (21.7 Inch)
Maximum Resolution : 1920 X 1080
Support Standby Mode : No
Support Suspend Mode : No
Support Low-Power Mode : Yes
Support Default GTF : No
Digital : Yes
Supported Display Modes :
720 X 400 70 Hz
640 X 480 60 Hz
640 X 480 67 Hz
640 X 480 72 Hz
640 X 480 75 Hz
800 X 600 56 Hz
800 X 600 60 Hz
800 X 600 72 Hz
800 X 600 75 Hz
832 X 624 75 Hz
1024 X 768 60 Hz
1024 X 768 70 Hz
1024 X 768 75 Hz
1280 X 720 60 Hz
1152 X 864 75 Hz
1280 X 960 60 Hz
1440 X 900 60 Hz
1280 X 1024 60 Hz
1280 X 1024 75 Hz
1680 X 1050 60 Hz
1920 X 1080 60 Hz
*****************************************************************
*****************************************************************
Active : Yes
Registry Key : DISPLAY\IVO8C66\5&462698&0&UID256
Manufacture Week : 0 / 2019
ManufacturerID : 53030 (0xCF26)
ProductID : 35942 (0x8C66)
Serial Number (Numeric) : 0 (0x00000000)
EDID Version : 1.4
Display Gamma : 2.20
Maximum Image Size : 31 X 17 cm (13.9 Inch)
Maximum Resolution : 1920 X 1080
Support Standby Mode : No
Support Suspend Mode : No
Support Low-Power Mode : No
Support Default GTF : No
Digital : Yes
Supported Display Modes :
1920 X 1080 60 Hz
The script here gives me almost what I want except it doesn't give me the monitor name nor does it give me information whether it's internal or not.
I have attached 2 screenshots from the Settings > Display > Advanced Display page which is the information I am looking to capture.

Unable to Determine why Frame Too Large For GIF Govips

I am trying to resize the following GIF
Original Dimensions are: 1270 x 1270 and a total of 149 Pages
I am resizing to the following Dimensions:
250 x 250 (Successful)
500 x 500 (Successful)
750 x 750 (Unsuccessful)
It fails for the last case and after some digging I found that the limits are set in libvips. I am not able to conclude how the dimensions are violating the constraints.
Constraints Being:
if( (guint64) frame_rect.width * frame_rect.height > INT_MAX / 4 ||
frame_rect.width > 65535 ||
frame_rect.height > 65535 ) {
vips_error( class->nickname, "%s", _( "frame too large" ) );
return( -1 );
}
Currently I have the latest govips(v2.11.0) and vips(8.13.3) versions installed.
I tried different sizes and it is working till 740 x 740. I tried to change the Export Params but am unable to figure the math behind why the frame is too large.

X11 (xorg) fails to set/change resolution (linux x86)

I'm trying to get a 10-inch touch display (native resolution: 1280x800) to switch to 1024x768, but everything I try is either ignored or results in an error. The display reportedly supports the resolution, though, xrandr --verbose reports (I'm using the default VESA driver):
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 640 x 480, current 640 x 480, maximum 1280 x 800
default connected 640x480+0+0 (0x180) normal (normal) 0mm x 0mm
Identifier: 0x17d
Timestamp: 635022581
Subpixel: horizontal rgb
Clones:
CRTC: 0
CRTCs: 0
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
1280x800 (0x17e) 0.0MHz
h: width 1280 start 0 end 0 total 1280 skew 0 clock 0.0KHz
v: height 800 start 0 end 0 total 800 clock 0.0Hz
800x600 (0x17f) 0.0MHz
h: width 800 start 0 end 0 total 800 skew 0 clock 0.0KHz
v: height 600 start 0 end 0 total 600 clock 0.0Hz
640x480 (0x180) 0.0MHz *current
h: width 640 start 0 end 0 total 640 skew 0 clock 0.0KHz
v: height 480 start 0 end 0 total 480 clock 0.0Hz
1024x768 (0x181) 0.0MHz
h: width 1024 start 0 end 0 total 1024 skew 0 clock 0.0KHz
v: height 768 start 0 end 0 total 768 clock 0.0Hz
If I try to change the resolution via xrandr --output default --mode 1027x768, i just get:
xrandr: Failed to get size of gamma for output default
xrandr: Configure crtc 0 failed
As far as I can see, only the second line is relevant to my problem; I don't know why xrandr would want to configre crtc 0, though, I only have the touch screen connected.
Failing that, I tried to configure the mode directly using the following xorg.conf:
Section "InputClass"
Identifier "calibration"
MatchProduct "DIALOGUE INC PenMount USB"
Option "Calibration" "95 911 93 919"
Option "SwapAxes" "0"
EndSection
Section "Monitor"
Identifier "disp0"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection
Section "Device"
Identifier "card0"
Driver "vesa"
EndSection
Section "Screen"
Identifier "src0"
Device "card0"
Monitor "disp0"
SubSection "Display"
Modes "1024x768_60.00" "1024x768"
EndSubSection
EndSection
Unfortunately, This doesn't work, either Xorg.log shows the following:
[634043.694] (II) VESA(0): Not using mode "1024x768_60.00" (no mode of this name)
[634043.694] (II) VESA(0): Not using built-in mode "1024x768" (no mode of this name)
Why doesn't this work? And what else can I try to get the display to switch to 1024x768?
I've uploaded the full logfile to Pastebin.
You can try to perform the following actions
cvt -r 1024 768
xrandr --newmode "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
xrandr --addmode default 1024x768_60.00
xrandr --output default --mode 1024x768_60.00

CGDisplayModeGetWidth/Height() sometimes returns pixels, sometimes points

According to Apple, both CGDisplayModeGetWidth() and CGDisplayModeGetHeight() should return points instead of pixels starting in macOS 10.8. But Apple's word on those APIs isn't consistent because here they say that the functions return pixels and not points.
This confusion is also reflected in practice because both functions only seem to return points sometimes, not all the time. Sometimes they also return pixels. Consider this example:
CGDirectDisplayID id = CGMainDisplayID();
CFArrayRef modes = CGDisplayCopyAllDisplayModes(id, NULL);
CGDisplayModeRef mode;
int c = 0, k, n;
n = CFArrayGetCount(modes);
for(k = 0; k < n; k++) {
mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, k);
printf("GOT SIZE: %d %d\n", (int) CGDisplayModeGetWidth(mode), (int) CGDisplayModeGetHeight(mode));
}
CFRelease(modes);
The code iterates over all available screen modes. In this example, the output is in pixels.
When using this code, however, the output is in points:
CGDirectDisplayID id = CGMainDisplayID();
mode = CGDisplayCopyDisplayMode(id);
printf("NEW GOT SIZE: %d %d\n", (int) CGDisplayModeGetWidth(mode), (int) CGDisplayModeGetHeight(mode));
CGDisplayModeRelease(mode);
But why? Why do CGDisplayModeGetWidth() and CGDisplayModeGetHeight() return pixels in the first code snippet and points in the second? This is confusing me.
To make things even more complicated, starting with macOS 10.8 there are two new APIs, namely CGDisplayModeGetPixelWidth() and CGDisplayModeGetPixelHeight(). These always return pixels, but I still don't understand why CGDisplayModeGetWidth() and CGDisplayModeGetHeight() return pixels in the first code snippet above... is this a bug?
EDIT
Here is the output for my 1680x1050 monitor. I am using Quartz Debug to put the monitor in 840x525 screen mode to do Retina tests. You can see that the output of the first code snippet must be in pixels because it returns modes such as 1680x1050 which would correspond to 3360x2100 pixels if it were points. Another proof that the first code snippet returns pixels not points lies in the fact that the screen mode the monitor is currently in (i.e. 840x525) isn't returned at all. Only the second code snippet returns this mode.
GOT SIZE: 1680 1050
GOT SIZE: 1152 870
GOT SIZE: 1280 1024
GOT SIZE: 1024 768
GOT SIZE: 1024 768
GOT SIZE: 1024 768
GOT SIZE: 832 624
GOT SIZE: 800 600
GOT SIZE: 800 600
GOT SIZE: 800 600
GOT SIZE: 800 600
GOT SIZE: 640 480
GOT SIZE: 640 480
GOT SIZE: 640 480
GOT SIZE: 640 480
GOT SIZE: 1280 1024
GOT SIZE: 1280 960
GOT SIZE: 848 480
GOT SIZE: 1280 960
GOT SIZE: 1360 768
GOT SIZE: 800 500
GOT SIZE: 1024 640
GOT SIZE: 1280 800
GOT SIZE: 1344 1008
GOT SIZE: 1344 840
GOT SIZE: 1600 1000
--------------------------
NEW GOT SIZE: 840 525

MATLAB: finding values in one array and using those locations to change values in one channel of a separate 3 channel array

So I have a labeled array (array1) with connected regions of interest (background is all zeros, connected regions are all 1's for the first region, all 2's for the second, 3's for the 3rd etc.) I also have a vector (vector1) of the region labels I find important (ex. 1,6,9). I want to find the locations of these values in the labeled array and then change values in one channel of a separate 3 channel array at the same locations (want to color certain parts of an image green based regions of interest found in another image).
I can use the below code to change all channels, but don't know how to specify (img(y,x,1=0), img(y,x,2=0), img(y,x,3=255)).
for i=1:1:length(vector1)
img(array1==vector1(i))=255;
end
If I understand you correctly, you have a label map of objects - each with an associated ID with 0 as the background. You also have a vector of important IDs and a colour image that is associated with this label map.
You wish to set all locations that have an important ID to 1 colour. I would first create a logical mask where true means that the pixel is important and false otherwise. What I mean by important is that the pixel is either 1, 6 or 9 if we go with your example. You can use bsxfun combined with any to create this mask, then we can use this to index into your image and set the right colour to these locations.
Therefore, do this:
%// Create your logical mask
mask3D = bsxfun(#eq, array1, permute(vector(:), [3 2 1]));
mask = any(mask3D, 3);
%// Set the image pixels to blue at these locations
red = img(:,:,1);
green = img(:,:,2);
blue = img(:,:,3);
red(mask) = 0;
green(mask) = 0;
blue(mask) = 255;
img = cat(3, red, green, blue);
Here's a quick example run. Suppose we have this image with squares:
We can see that there are three squares. Let's change object 1 and object 3 to blue. Before we do that, we need to get a label map:
%// Originally a binary image
im = imread('http://i.stack.imgur.com/DnYQS.png');
%// Get label map
array1 = bwlabel(im);
%// Create colour version out of this binary image
img = 255*uint8(im);
img = cat(3, img, img, img);
array1 is our label map as you have also mentioned in your question and img is the colour version of the input image. Now, vector = [1 3] so we can change those objects. The labelling is such that the top left square is label 1, the middle is label 2 and the bottom right is label 3.
Once I do this and I run the above code, this is the image I get:
You can achieve it in two lines -
%// Create a 3D mask to select the labels [1,6,9] only, as listed in "vector1"
mask = bsxfun(#and,ismember(array1,vector1),ones(1,1,3));
%// Map "img" with "mask" and set them to tuple:[0,0,255] (blue color)
img(mask) = reshape(repmat([0 0 255],nnz(mask)/3,1),[],1)
Sample run -
array1 = %// Input
2 0 1 1 0 6
0 0 1 0 0 6
9 0 0 0 0 6
9 9 0 4 0 0
vector1 = %// Input
1 6 9
img(:,:,1) = %// Input: Before code run
228 19 175 30 192 188
204 23 34 164 149 248
188 204 185 84 189 222
14 241 29 167 60 22
img(:,:,2) =
94 202 197 59 200 136
95 94 53 164 26 24
175 53 100 124 75 104
153 23 141 39 61 27
img(:,:,3) =
29 246 111 48 197 172
201 111 168 68 101 110
75 178 28 204 70 116
154 194 239 125 10 156
img(:,:,1) = %// Output: After code run
228 19 0 0 192 0
204 23 0 164 149 0
0 204 185 84 189 0
0 0 29 167 60 22
img(:,:,2) =
94 202 0 0 200 0
95 94 0 164 26 0
0 53 100 124 75 0
0 0 141 39 61 27
img(:,:,3) =
29 246 255 255 197 255
201 111 255 68 101 255
255 178 28 204 70 255
255 255 239 125 10 156
Notice the positions of the values [1,6,9] in array1 and the corresponding value changes in img1 before and after code runs.

Resources