It is currently April 16th, 2024, 12:44 pm

Quantization value for histograms

Report bugs with the Rainmeter application and suggest features.
ronzino
Posts: 22
Joined: June 4th, 2020, 4:41 pm

Quantization value for histograms

Post by ronzino »

As far I have understood, histograms works like this: " at every meter update, a column having a base of 1 pixel is drawn"

should be possible to specify the with (number of pixel) a column is made by ?
I mean, if you look an histogram on an high resolution display, or quite far from it, just 1px is too small to see.

Of course doing so, the viewing windows of the histogram is reduced by a factor equal to column width, but this is a user's decision.

thanks
User avatar
balala
Rainmeter Sage
Posts: 16142
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Quantization value for histograms

Post by balala »

ronzino wrote: July 4th, 2020, 5:26 pm should be possible to specify the with (number of pixel) a column is made by ?
No, unfortunately, at least as far as I can tell, this is not possible. Sorry...
User avatar
balala
Rainmeter Sage
Posts: 16142
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Quantization value for histograms

Post by balala »

Sorry, in fact I just realized it is possible. You have to use the TransormationMatrix option.

For instance if you add a TransormationMatrix=2;0;0;1;0;0, it'll do exactly what have you asked for. The only inconvenience is that the Histogram meter having this option added, moves horizontally, unless it has the X position set to X=0 (in this case, it doesn't move). But this can be easily fixed, by replacing the fifth parameter of the TransformationMatrix option with the value of its X option, negated. For example if the Histogram meter has an X=20 option set, a TransformationMatrix=2;0;0;1;-20;0 (see its fifth parameter is -X), extends the Histogram meter as you asked for, without moving it horizontally.
If you have questions related to TransformationMatrix, first please read the Transformation Matrix Guide (sorry, quite large), then, if you still have questions (and you probably will have), come back to the forum and ask.
User avatar
Yincognito
Rainmeter Sage
Posts: 7118
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Quantization value for histograms

Post by Yincognito »

ronzino wrote: July 4th, 2020, 5:26 pm As far I have understood, histograms works like this: " at every meter update, a column having a base of 1 pixel is drawn"

should be possible to specify the with (number of pixel) a column is made by ?
I mean, if you look an histogram on an high resolution display, or quite far from it, just 1px is too small to see.

Of course doing so, the viewing windows of the histogram is reduced by a factor equal to column width, but this is a user's decision.

thanks
If you really really want to, a histogram can be replicated / simulated using a couple of Bar meters, on which you can set the width. "Moving" / "updating" those bars on a "timeline" and simulating multiple "histograms" are possible obstacles in implementing this, but they are not that serious, especially if using dynamically modified meters. Another possibility would be to use either dynamically updated Path Shape meters or even dynamically updated Line Shape meters that you'd set the desired StrokeWidth on.

Anway, the point is that it definitely is possible, and not exaggerately difficult to implement. The Bar and Line variants would require a number of meters equal to the number of "value points" you have in the histogram, and the Path variant, while possible in a single meter / shape, would need separate filling of the area "below" the "value points", if the path is an open shape.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16142
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Quantization value for histograms

Post by balala »

Yincognito wrote: July 5th, 2020, 4:28 pm If you really really want to, a histogram can be replicated / simulated using a couple of Bar meters, on which you can set the width. "Moving" / "updating" those bars on a "timeline" and simulating multiple "histograms" are possible obstacles in implementing this, but they are not that serious, especially if using dynamically modified meters. Another possibility would be to use either dynamically updated Path Shape meters or even dynamically updated Line Shape meters that you'd set the desired StrokeWidth on.
I definitely would be curious how would you do this.
User avatar
Yincognito
Rainmeter Sage
Posts: 7118
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Quantization value for histograms

Post by Yincognito »

balala wrote: July 5th, 2020, 5:16 pm I definitely would be curious how would you do this.
I'm willing to satisfy your curiosity, balala. :D Just choose your desired method and I'll show you. 8-)
Or, if you challenge me, I'll do it using all 3 methods, as I always respond to challenges... :sly:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16142
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Quantization value for histograms

Post by balala »

Yincognito wrote: July 5th, 2020, 5:51 pm I'm willing to satisfy your curiosity, balala. :D Just choose your desired method and I'll show you. 8-)
Or, if you challenge me, I'll do it using all 3 methods, as I always respond to challenges... :sly:
No need for three methods. The Bar meter method would be fine.

EDIT: For instance here is an extremely simple code. Could you replace the [MeterCPUHistogram] Histogram meter with Bar meters?

Code: Select all

[Rainmeter]
Update=1000

[MeasureRand]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=0
HighBound=100
MinValue=0
MaxValue=100

[MeterCPUHistogram]
Meter=Histogram
MeasureName=MeasureRand
X=5
Y=5
W=210
H=60
PrimaryColor=255,255,255,255
SolidColor=0,0,0,100
AntiAlias=1
User avatar
Yincognito
Rainmeter Sage
Posts: 7118
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Quantization value for histograms

Post by Yincognito »

balala wrote: July 5th, 2020, 6:05 pmNo need for three methods. The Bar meter method would be fine.
Okeydokey. I'll use the Histogram meter example in the manual as a basis for the bar implementation. I'll let both the histogram and the bar meters so one can see the similarity. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16142
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Quantization value for histograms

Post by balala »

Yincognito wrote: July 5th, 2020, 6:17 pm Okeydokey. I'll use the Histogram meter example in the manual as a basis for the bar implementation. I'll let both the histogram and the bar meters so one can see the similarity. ;-)
Alright. Waiting for your implementation. :thumbup:
User avatar
Yincognito
Rainmeter Sage
Posts: 7118
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Quantization value for histograms

Post by Yincognito »

balala wrote: July 5th, 2020, 6:36 pm Alright. Waiting for your implementation. :thumbup:
There you go (just 5 value points used, as I didn't want to bother copy pasting too much):

Code: Select all

[Variables]
H=500

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

---Measures---

[MeasureCPU]
Measure=CPU
OnUpdateAction=[!SetOption MeasureCPUValues String "[MeasureCPUValues][MeasureCPU],"]
DynamicVariables=1

[MeasureCPUValues]
Measure=String
String=0.0,0.0,0.0,0.0,0.0,
RegExpSubstitute=1
Substitute="(?siU)^(?:.*,){1}((?:.*,){5})$":"\1"
DynamicVariables=1

[MeasureCPUValueS0]
Measure=String
String=[MeasureCPUValues]
RegExpSubstitute=1
Substitute="(?siU)^(?:.*,){0}(.*),.*$":"\1"
DynamicVariables=1

[MeasureCPUValue0]
Measure=Calc
Formula=[MeasureCPUValueS0]
MinValue=0
MaxValue=100
DynamicVariables=1

[MeasureCPUValueS1]
Measure=String
String=[MeasureCPUValues]
RegExpSubstitute=1
Substitute="(?siU)^(?:.*,){1}(.*),.*$":"\1"
DynamicVariables=1

[MeasureCPUValue1]
Measure=Calc
Formula=[MeasureCPUValueS1]
MinValue=0
MaxValue=100
DynamicVariables=1

[MeasureCPUValueS2]
Measure=String
String=[MeasureCPUValues]
RegExpSubstitute=1
Substitute="(?siU)^(?:.*,){2}(.*),.*$":"\1"
DynamicVariables=1

[MeasureCPUValue2]
Measure=Calc
Formula=[MeasureCPUValueS2]
MinValue=0
MaxValue=100
DynamicVariables=1

[MeasureCPUValueS3]
Measure=String
String=[MeasureCPUValues]
RegExpSubstitute=1
Substitute="(?siU)^(?:.*,){3}(.*),.*$":"\1"
DynamicVariables=1

[MeasureCPUValue3]
Measure=Calc
Formula=[MeasureCPUValueS3]
MinValue=0
MaxValue=100
DynamicVariables=1

[MeasureCPUValueS4]
Measure=String
String=[MeasureCPUValues]
RegExpSubstitute=1
Substitute="(?siU)^(?:.*,){4}(.*),.*$":"\1"
DynamicVariables=1

[MeasureCPUValue4]
Measure=Calc
Formula=[MeasureCPUValueS4]
MinValue=0
MaxValue=100
DynamicVariables=1

---Meters---

[MeterCPUBackgroundImage]
Meter=Image
SolidColor=24,102,10
X=0
Y=0
W=220
H=(#H#+10)

[MeterCPUHistogram]
Meter=Histogram
MeasureName=MeasureCPU
X=5
Y=5
W=5
H=#H#
PrimaryColor=255,255,255,255
SolidColor=0,0,0,100
AntiAlias=1

[MeterImageGap]
Meter=Image
X=0R
Y=0r
W=10
H=#H#
SolidColor=0,0,0,0
AntiAlias=1

[MeterCPUBar0]
Meter=Bar
MeasureName=MeasureCPUValue0
X=0R
Y=0r
W=(195/5)
H=#H#
BarColor=255,255,255,255
SolidColor=0,0,0,100
BarOrientation=Vertical
DynamicVariables=1

[MeterCPUBar1]
Meter=Bar
MeasureName=MeasureCPUValue1
X=0R
Y=0r
W=(195/5)
H=#H#
BarColor=255,255,255,255
SolidColor=0,0,0,100
BarOrientation=Vertical
DynamicVariables=1

[MeterCPUBar2]
Meter=Bar
MeasureName=MeasureCPUValue2
X=0R
Y=0r
W=(195/5)
H=#H#
BarColor=255,255,255,255
SolidColor=0,0,0,100
BarOrientation=Vertical
DynamicVariables=1

[MeterCPUBar3]
Meter=Bar
MeasureName=MeasureCPUValue3
X=0R
Y=0r
W=(195/5)
H=#H#
BarColor=255,255,255,255
SolidColor=0,0,0,100
BarOrientation=Vertical
DynamicVariables=1

[MeterCPUBar4]
Meter=Bar
MeasureName=MeasureCPUValue4
X=0R
Y=0r
W=(195/5)
H=#H#
BarColor=255,255,255,255
SolidColor=0,0,0,100
BarOrientation=Vertical
DynamicVariables=1

[MeterCPUText]
Meter=String
MeasureName=MeasureCPU
X=110
Y=10R
FontSize=13
FontColor=255,255,255,255
StringAlign=Center
AntiAlias=1
Text=CPU Usage: %1%
I chose to work with strings as I found it easier than passing measure values to predecessor measures (the latter being just another way of doing it). Even though the string formatting was easy and quick, got delayed by regular Rainmeter coding issues like setting dynamic variables or creating additional Calc measures to serve as intermediaries (I initially wanted to pass already formatted "percentual string values" to the measures used in bars, but Rainmeter insisted on having additional Calc steps, so...), that kind of stuff.

The idea here was to create a string "chain" with all the values, in the form of "PastValue4, PastValue3, PastValue2, PastValue1, CurrentValue" (5 value points used here for simplicity, but can be as many as desired), where PastValue4 is deleted from the start and another CurrentValue is inserted at the end, on subsequent updates. This "chain" / "set" is then distributed to the 5 individual String measures where each string value is extracted. Then, 5 percentual Calc measures use those string values and are linked to the corresponding meters.

As I said, this can also be done by passing measure values to predecessor measures, but I thought that approach might cause slight issues due to the dynamic variables, so went for the String approach.

P.S. I set the height of the histograms to 500px, to better see the whole thing in motion.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth